abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kit.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "misc/extra/extraBdd.h"
#include "cloud.h"

Go to the source code of this file.

Data Structures

struct  Kit_Sop_t_
 
struct  Kit_Edge_t_
 
struct  Kit_Node_t_
 
struct  Kit_Graph_t_
 
struct  Kit_DsdObj_t_
 
struct  Kit_DsdNtk_t_
 
struct  Kit_DsdMan_t_
 

Macros

#define Kit_DsdNtkForEachObj(pNtk, pObj, i)   for ( i = 0; (i < (pNtk)->nNodes) && ((pObj) = (pNtk)->pNodes[i]); i++ )
 
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)   for ( i = 0; (i < (int)(pObj)->nFans) && ((iLit) = (pObj)->pFans[i], 1); i++ )
 
#define Kit_DsdObjForEachFaninReverse(pNtk, pObj, iLit, i)   for ( i = (int)(pObj)->nFans - 1; (i >= 0) && ((iLit) = (pObj)->pFans[i], 1); i-- )
 
#define Kit_PlaForEachCube(pSop, nFanins, pCube)   for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )
 
#define Kit_PlaCubeForEachVar(pCube, Value, i)   for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )
 
#define KIT_MIN(a, b)   (((a) < (b))? (a) : (b))
 MACRO DEFINITIONS ///. More...
 
#define KIT_MAX(a, b)   (((a) > (b))? (a) : (b))
 
#define KIT_INFINITY   (100000000)
 
#define Kit_SopForEachCube(cSop, uCube, i)   for ( i = 0; (i < Kit_SopCubeNum(cSop)) && ((uCube) = Kit_SopCube(cSop, i)); i++ )
 ITERATORS ///. More...
 
#define Kit_CubeForEachLiteral(uCube, Lit, nLits, i)   for ( i = 0; (i < (nLits)) && ((Lit) = Kit_CubeHasLit(uCube, i)); i++ )
 
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)   for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Kit_GraphNode(pGraph, i)), 1); i++ )
 
#define Kit_GraphForEachNode(pGraph, pAnd, i)   for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Kit_GraphNode(pGraph, i)), 1); i++ )
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Kit_Sop_t_ 
Kit_Sop_t
 INCLUDES ///. More...
 
typedef struct Kit_Edge_t_ Kit_Edge_t
 
typedef struct Kit_Node_t_ Kit_Node_t
 
typedef struct Kit_Graph_t_ Kit_Graph_t
 
typedef struct Kit_DsdObj_t_ Kit_DsdObj_t
 
typedef struct Kit_DsdNtk_t_ Kit_DsdNtk_t
 
typedef struct Kit_DsdMan_t_ Kit_DsdMan_t
 

Enumerations

enum  Kit_Dsd_t {
  KIT_DSD_NONE = 0, KIT_DSD_CONST1, KIT_DSD_VAR, KIT_DSD_AND,
  KIT_DSD_XOR, KIT_DSD_PRIME
}
 

Functions

static unsigned Kit_DsdObjOffset (int nFans)
 
static unsigned * Kit_DsdObjTruth (Kit_DsdObj_t *pObj)
 
static int Kit_DsdNtkObjNum (Kit_DsdNtk_t *pNtk)
 
static Kit_DsdObj_tKit_DsdNtkObj (Kit_DsdNtk_t *pNtk, int Id)
 
static Kit_DsdObj_tKit_DsdNtkRoot (Kit_DsdNtk_t *pNtk)
 
static int Kit_DsdLitIsLeaf (Kit_DsdNtk_t *pNtk, int Lit)
 
static unsigned Kit_DsdLitSupport (Kit_DsdNtk_t *pNtk, int Lit)
 
static int Kit_CubeHasLit (unsigned uCube, int i)
 
static unsigned Kit_CubeSetLit (unsigned uCube, int i)
 
static unsigned Kit_CubeXorLit (unsigned uCube, int i)
 
static unsigned Kit_CubeRemLit (unsigned uCube, int i)
 
static int Kit_CubeContains (unsigned uLarge, unsigned uSmall)
 
static unsigned Kit_CubeSharp (unsigned uCube, unsigned uMask)
 
static unsigned Kit_CubeMask (int nVar)
 
static int Kit_CubeIsMarked (unsigned uCube)
 
static unsigned Kit_CubeMark (unsigned uCube)
 
static unsigned Kit_CubeUnmark (unsigned uCube)
 
static int Kit_SopCubeNum (Kit_Sop_t *cSop)
 
static unsigned Kit_SopCube (Kit_Sop_t *cSop, int i)
 
static void Kit_SopShrink (Kit_Sop_t *cSop, int nCubesNew)
 
static void Kit_SopPushCube (Kit_Sop_t *cSop, unsigned uCube)
 
static void Kit_SopWriteCube (Kit_Sop_t *cSop, unsigned uCube, int i)
 
static Kit_Edge_t Kit_EdgeCreate (int Node, int fCompl)
 
static unsigned Kit_EdgeToInt (Kit_Edge_t eEdge)
 
static Kit_Edge_t Kit_IntToEdge (unsigned Edge)
 
static unsigned Kit_EdgeToInt_ (Kit_Edge_t m)
 
static Kit_Edge_t Kit_IntToEdge_ (unsigned m)
 
static int Kit_GraphIsConst (Kit_Graph_t *pGraph)
 
static int Kit_GraphIsConst0 (Kit_Graph_t *pGraph)
 
static int Kit_GraphIsConst1 (Kit_Graph_t *pGraph)
 
static int Kit_GraphIsComplement (Kit_Graph_t *pGraph)
 
static int Kit_GraphIsVar (Kit_Graph_t *pGraph)
 
static void Kit_GraphComplement (Kit_Graph_t *pGraph)
 
static void Kit_GraphSetRoot (Kit_Graph_t *pGraph, Kit_Edge_t eRoot)
 
static int Kit_GraphLeaveNum (Kit_Graph_t *pGraph)
 
static int Kit_GraphNodeNum (Kit_Graph_t *pGraph)
 
static Kit_Node_tKit_GraphNode (Kit_Graph_t *pGraph, int i)
 
static Kit_Node_tKit_GraphNodeLast (Kit_Graph_t *pGraph)
 
static int Kit_GraphNodeInt (Kit_Graph_t *pGraph, Kit_Node_t *pNode)
 
static int Kit_GraphNodeIsVar (Kit_Graph_t *pGraph, Kit_Node_t *pNode)
 
static Kit_Node_tKit_GraphVar (Kit_Graph_t *pGraph)
 
static int Kit_GraphVarInt (Kit_Graph_t *pGraph)
 
static Kit_Node_tKit_GraphNodeFanin0 (Kit_Graph_t *pGraph, Kit_Node_t *pNode)
 
static Kit_Node_tKit_GraphNodeFanin1 (Kit_Graph_t *pGraph, Kit_Node_t *pNode)
 
static int Kit_GraphRootLevel (Kit_Graph_t *pGraph)
 
static int Kit_SuppIsMinBase (int Supp)
 
static int Kit_BitWordNum (int nBits)
 
static int Kit_TruthWordNum (int nVars)
 
static unsigned Kit_BitMask (int nBits)
 
static void Kit_TruthSetBit (unsigned *p, int Bit)
 
static void Kit_TruthXorBit (unsigned *p, int Bit)
 
static int Kit_TruthHasBit (unsigned *p, int Bit)
 
static int Kit_WordFindFirstBit (unsigned uWord)
 
static int Kit_WordHasOneBit (unsigned uWord)
 
static int Kit_WordCountOnes (unsigned uWord)
 
static int Kit_TruthCountOnes (unsigned *pIn, int nVars)
 
static int Kit_TruthFindFirstBit (unsigned *pIn, int nVars)
 
static int Kit_TruthFindFirstZero (unsigned *pIn, int nVars)
 
static int Kit_TruthIsEqual (unsigned *pIn0, unsigned *pIn1, int nVars)
 
static int Kit_TruthIsEqualWithCare (unsigned *pIn0, unsigned *pIn1, unsigned *pCare, int nVars)
 
static int Kit_TruthIsOpposite (unsigned *pIn0, unsigned *pIn1, int nVars)
 
static int Kit_TruthIsEqualWithPhase (unsigned *pIn0, unsigned *pIn1, int nVars)
 
static int Kit_TruthIsConst0 (unsigned *pIn, int nVars)
 
static int Kit_TruthIsConst1 (unsigned *pIn, int nVars)
 
static int Kit_TruthIsImply (unsigned *pIn1, unsigned *pIn2, int nVars)
 
static int Kit_TruthIsDisjoint (unsigned *pIn1, unsigned *pIn2, int nVars)
 
static int Kit_TruthIsDisjoint3 (unsigned *pIn1, unsigned *pIn2, unsigned *pIn3, int nVars)
 
static void Kit_TruthCopy (unsigned *pOut, unsigned *pIn, int nVars)
 
static void Kit_TruthClear (unsigned *pOut, int nVars)
 
static void Kit_TruthFill (unsigned *pOut, int nVars)
 
static void Kit_TruthNot (unsigned *pOut, unsigned *pIn, int nVars)
 
static void Kit_TruthAnd (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static void Kit_TruthOr (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static void Kit_TruthXor (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static void Kit_TruthSharp (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static void Kit_TruthNand (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
 
static void Kit_TruthAndPhase (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars, int fCompl0, int fCompl1)
 
static void Kit_TruthOrPhase (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars, int fCompl0, int fCompl1)
 
static void Kit_TruthMux (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, unsigned *pCtrl, int nVars)
 
static void Kit_TruthMuxPhase (unsigned *pOut, unsigned *pIn0, unsigned *pIn1, unsigned *pCtrl, int nVars, int fComp0)
 
static void Kit_TruthIthVar (unsigned *pTruth, int nVars, int iVar)
 
DdNodeKit_SopToBdd (DdManager *dd, Kit_Sop_t *cSop, int nVars)
 FUNCTION DECLARATIONS ///. More...
 
DdNodeKit_GraphToBdd (DdManager *dd, Kit_Graph_t *pGraph)
 
DdNodeKit_TruthToBdd (DdManager *dd, unsigned *pTruth, int nVars, int fMSBonTop)
 
CloudNodeKit_TruthToCloud (CloudManager *dd, unsigned *pTruth, int nVars)
 
unsigned * Kit_CloudToTruth (Vec_Int_t *vNodes, int nVars, Vec_Ptr_t *vStore, int fInv)
 
int Kit_CreateCloud (CloudManager *dd, CloudNode *pFunc, Vec_Int_t *vNodes)
 
int Kit_CreateCloudFromTruth (CloudManager *dd, unsigned *pTruth, int nVars, Vec_Int_t *vNodes)
 
unsigned * Kit_TruthCompose (CloudManager *dd, unsigned *pTruth, int nVars, unsigned **pInputs, int nVarsAll, Vec_Ptr_t *vStore, Vec_Int_t *vNodes)
 
void Kit_TruthCofSupports (Vec_Int_t *vBddDir, Vec_Int_t *vBddInv, int nVars, Vec_Int_t *vMemory, unsigned *puSupps)
 
Kit_DsdMan_tKit_DsdManAlloc (int nVars, int nNodes)
 DECLARATIONS ///. More...
 
void Kit_DsdManFree (Kit_DsdMan_t *p)
 
Kit_DsdNtk_tKit_DsdDeriveNtk (unsigned *pTruth, int nVars, int nLutSize)
 
unsigned * Kit_DsdTruthCompute (Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk)
 
void Kit_DsdTruth (Kit_DsdNtk_t *pNtk, unsigned *pTruthRes)
 
void Kit_DsdTruthPartial (Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned *pTruthRes, unsigned uSupp)
 
void Kit_DsdTruthPartialTwo (Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp, int iVar, unsigned *pTruthCo, unsigned *pTruthDec)
 
void Kit_DsdPrint (FILE *pFile, Kit_DsdNtk_t *pNtk)
 
void Kit_DsdPrintExpanded (Kit_DsdNtk_t *pNtk)
 
void Kit_DsdPrintFromTruth (unsigned *pTruth, int nVars)
 
void Kit_DsdPrintFromTruth2 (FILE *pFile, unsigned *pTruth, int nVars)
 
void Kit_DsdWriteFromTruth (char *pBuffer, unsigned *pTruth, int nVars)
 
Kit_DsdNtk_tKit_DsdDecompose (unsigned *pTruth, int nVars)
 
Kit_DsdNtk_tKit_DsdDecomposeExpand (unsigned *pTruth, int nVars)
 
Kit_DsdNtk_tKit_DsdDecomposeMux (unsigned *pTruth, int nVars, int nDecMux)
 
void Kit_DsdVerify (Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
 
void Kit_DsdNtkFree (Kit_DsdNtk_t *pNtk)
 
int Kit_DsdNonDsdSizeMax (Kit_DsdNtk_t *pNtk)
 
Kit_DsdObj_tKit_DsdNonDsdPrimeMax (Kit_DsdNtk_t *pNtk)
 
unsigned Kit_DsdNonDsdSupports (Kit_DsdNtk_t *pNtk)
 
int Kit_DsdCountAigNodes (Kit_DsdNtk_t *pNtk)
 
unsigned Kit_DsdGetSupports (Kit_DsdNtk_t *p)
 
Kit_DsdNtk_tKit_DsdExpand (Kit_DsdNtk_t *p)
 
Kit_DsdNtk_tKit_DsdShrink (Kit_DsdNtk_t *p, int pPrios[])
 
void Kit_DsdRotate (Kit_DsdNtk_t *p, int pFreqs[])
 
int Kit_DsdCofactoring (unsigned *pTruth, int nVars, int *pCofVars, int nLimit, int fVerbose)
 
Kit_Graph_tKit_SopFactor (Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
 FUNCTION DEFINITIONS ///. More...
 
Kit_Graph_tKit_GraphCreate (int nLeaves)
 DECLARATIONS ///. More...
 
Kit_Graph_tKit_GraphCreateConst0 ()
 
Kit_Graph_tKit_GraphCreateConst1 ()
 
Kit_Graph_tKit_GraphCreateLeaf (int iLeaf, int nLeaves, int fCompl)
 
void Kit_GraphFree (Kit_Graph_t *pGraph)
 
Kit_Node_tKit_GraphAppendNode (Kit_Graph_t *pGraph)
 
Kit_Edge_t Kit_GraphAddNodeAnd (Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
 
Kit_Edge_t Kit_GraphAddNodeOr (Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
 
Kit_Edge_t Kit_GraphAddNodeXor (Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1, int Type)
 
Kit_Edge_t Kit_GraphAddNodeMux (Kit_Graph_t *pGraph, Kit_Edge_t eEdgeC, Kit_Edge_t eEdgeT, Kit_Edge_t eEdgeE, int Type)
 
unsigned Kit_GraphToTruth (Kit_Graph_t *pGraph)
 
Kit_Graph_tKit_TruthToGraph (unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
 
int Kit_GraphLeafDepth_rec (Kit_Graph_t *pGraph, Kit_Node_t *pNode, Kit_Node_t *pLeaf)
 
int Kit_TruthIsop (unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
 FUNCTION DEFINITIONS ///. More...
 
void Kit_TruthIsopPrint (unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
 
void Kit_TruthIsopPrintCover (Vec_Int_t *vCover, int nVars, int fCompl)
 
int Kit_PlaIsConst0 (char *pSop)
 DECLARATIONS ///. More...
 
int Kit_PlaIsConst1 (char *pSop)
 
int Kit_PlaIsBuf (char *pSop)
 
int Kit_PlaIsInv (char *pSop)
 
int Kit_PlaGetVarNum (char *pSop)
 
int Kit_PlaGetCubeNum (char *pSop)
 
int Kit_PlaIsComplement (char *pSop)
 
void Kit_PlaComplement (char *pSop)
 
char * Kit_PlaStart (void *p, int nCubes, int nVars)
 
char * Kit_PlaCreateFromIsop (void *p, int nVars, Vec_Int_t *vCover)
 
void Kit_PlaToIsop (char *pSop, Vec_Int_t *vCover)
 
char * Kit_PlaStoreSop (void *p, char *pSop)
 
char * Kit_PlaFromTruth (void *p, unsigned *pTruth, int nVars, Vec_Int_t *vCover)
 
char * Kit_PlaFromTruthNew (unsigned *pTruth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vStr)
 
ABC_UINT64_T Kit_PlaToTruth6 (char *pSop, int nVars)
 
void Kit_PlaToTruth (char *pSop, int nVars, Vec_Ptr_t *vVars, unsigned *pTemp, unsigned *pTruth)
 
void Kit_SopCreate (Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
 DECLARATIONS ///. More...
 
void Kit_SopCreateInverse (Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
 
void Kit_SopDup (Kit_Sop_t *cResult, Kit_Sop_t *cSop, Vec_Int_t *vMemory)
 
void Kit_SopDivideByLiteralQuo (Kit_Sop_t *cSop, int iLit)
 
void Kit_SopDivideByCube (Kit_Sop_t *cSop, Kit_Sop_t *cDiv, Kit_Sop_t *vQuo, Kit_Sop_t *vRem, Vec_Int_t *vMemory)
 
void Kit_SopDivideInternal (Kit_Sop_t *cSop, Kit_Sop_t *cDiv, Kit_Sop_t *vQuo, Kit_Sop_t *vRem, Vec_Int_t *vMemory)
 
void Kit_SopMakeCubeFree (Kit_Sop_t *cSop)
 
int Kit_SopIsCubeFree (Kit_Sop_t *cSop)
 
void Kit_SopCommonCubeCover (Kit_Sop_t *cResult, Kit_Sop_t *cSop, Vec_Int_t *vMemory)
 
int Kit_SopAnyLiteral (Kit_Sop_t *cSop, int nLits)
 
int Kit_SopDivisor (Kit_Sop_t *cResult, Kit_Sop_t *cSop, int nLits, Vec_Int_t *vMemory)
 
void Kit_SopBestLiteralCover (Kit_Sop_t *cResult, Kit_Sop_t *cSop, unsigned uCube, int nLits, Vec_Int_t *vMemory)
 
void Kit_TruthSwapAdjacentVars (unsigned *pOut, unsigned *pIn, int nVars, int Start)
 DECLARATIONS ///. More...
 
void Kit_TruthStretch (unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
 
void Kit_TruthPermute (unsigned *pOut, unsigned *pIn, int nVars, char *pPerm, int fReturnIn)
 
void Kit_TruthShrink (unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
 
int Kit_TruthVarInSupport (unsigned *pTruth, int nVars, int iVar)
 
int Kit_TruthSupportSize (unsigned *pTruth, int nVars)
 
unsigned Kit_TruthSupport (unsigned *pTruth, int nVars)
 
void Kit_TruthCofactor0 (unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthCofactor1 (unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthCofactor0New (unsigned *pOut, unsigned *pIn, int nVars, int iVar)
 
void Kit_TruthCofactor1New (unsigned *pOut, unsigned *pIn, int nVars, int iVar)
 
int Kit_TruthVarIsVacuous (unsigned *pOnset, unsigned *pOffset, int nVars, int iVar)
 
void Kit_TruthExist (unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthExistNew (unsigned *pRes, unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthExistSet (unsigned *pRes, unsigned *pTruth, int nVars, unsigned uMask)
 
void Kit_TruthForall (unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthForallNew (unsigned *pRes, unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthForallSet (unsigned *pRes, unsigned *pTruth, int nVars, unsigned uMask)
 
void Kit_TruthUniqueNew (unsigned *pRes, unsigned *pTruth, int nVars, int iVar)
 
void Kit_TruthMuxVar (unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
 
void Kit_TruthMuxVarPhase (unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar, int fCompl0)
 
void Kit_TruthChangePhase (unsigned *pTruth, int nVars, int iVar)
 
int Kit_TruthVarsSymm (unsigned *pTruth, int nVars, int iVar0, int iVar1, unsigned *pCof0, unsigned *pCof1)
 
int Kit_TruthVarsAntiSymm (unsigned *pTruth, int nVars, int iVar0, int iVar1, unsigned *pCof0, unsigned *pCof1)
 
int Kit_TruthMinCofSuppOverlap (unsigned *pTruth, int nVars, int *pVarMin)
 
int Kit_TruthBestCofVar (unsigned *pTruth, int nVars, unsigned *pCof0, unsigned *pCof1)
 
void Kit_TruthCountOnesInCofs (unsigned *pTruth, int nVars, int *pStore)
 
void Kit_TruthCountOnesInCofs0 (unsigned *pTruth, int nVars, int *pStore)
 
void Kit_TruthCountOnesInCofsSlow (unsigned *pTruth, int nVars, int *pStore, unsigned *pAux)
 
unsigned Kit_TruthHash (unsigned *pIn, int nWords)
 
unsigned Kit_TruthSemiCanonicize (unsigned *pInOut, unsigned *pAux, int nVars, char *pCanonPerm)
 
char * Kit_TruthDumpToFile (unsigned *pTruth, int nVars, int nFile)
 
void Kit_TruthPrintProfile (unsigned *pTruth, int nVars)
 

Macro Definition Documentation

#define Kit_CubeForEachLiteral (   uCube,
  Lit,
  nLits,
 
)    for ( i = 0; (i < (nLits)) && ((Lit) = Kit_CubeHasLit(uCube, i)); i++ )

Definition at line 499 of file kit.h.

#define Kit_DsdNtkForEachObj (   pNtk,
  pObj,
 
)    for ( i = 0; (i < (pNtk)->nNodes) && ((pObj) = (pNtk)->pNodes[i]); i++ )

Definition at line 155 of file kit.h.

#define Kit_DsdObjForEachFanin (   pNtk,
  pObj,
  iLit,
 
)    for ( i = 0; (i < (int)(pObj)->nFans) && ((iLit) = (pObj)->pFans[i], 1); i++ )

Definition at line 157 of file kit.h.

#define Kit_DsdObjForEachFaninReverse (   pNtk,
  pObj,
  iLit,
 
)    for ( i = (int)(pObj)->nFans - 1; (i >= 0) && ((iLit) = (pObj)->pFans[i], 1); i-- )

Definition at line 159 of file kit.h.

#define Kit_GraphForEachLeaf (   pGraph,
  pLeaf,
 
)    for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Kit_GraphNode(pGraph, i)), 1); i++ )

Definition at line 502 of file kit.h.

#define Kit_GraphForEachNode (   pGraph,
  pAnd,
 
)    for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Kit_GraphNode(pGraph, i)), 1); i++ )

Definition at line 504 of file kit.h.

#define KIT_INFINITY   (100000000)

Definition at line 173 of file kit.h.

#define KIT_MAX (   a,
 
)    (((a) > (b))? (a) : (b))

Definition at line 172 of file kit.h.

#define KIT_MIN (   a,
 
)    (((a) < (b))? (a) : (b))

MACRO DEFINITIONS ///.

Definition at line 171 of file kit.h.

#define Kit_PlaCubeForEachVar (   pCube,
  Value,
 
)    for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )

Definition at line 164 of file kit.h.

#define Kit_PlaForEachCube (   pSop,
  nFanins,
  pCube 
)    for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )

Definition at line 162 of file kit.h.

#define Kit_SopForEachCube (   cSop,
  uCube,
 
)    for ( i = 0; (i < Kit_SopCubeNum(cSop)) && ((uCube) = Kit_SopCube(cSop, i)); i++ )

ITERATORS ///.

Definition at line 497 of file kit.h.

Typedef Documentation

typedef struct Kit_DsdMan_t_ Kit_DsdMan_t

Definition at line 134 of file kit.h.

typedef struct Kit_DsdNtk_t_ Kit_DsdNtk_t

Definition at line 121 of file kit.h.

typedef struct Kit_DsdObj_t_ Kit_DsdObj_t

Definition at line 108 of file kit.h.

typedef struct Kit_Edge_t_ Kit_Edge_t

Definition at line 59 of file kit.h.

typedef struct Kit_Graph_t_ Kit_Graph_t

Definition at line 85 of file kit.h.

typedef struct Kit_Node_t_ Kit_Node_t

Definition at line 66 of file kit.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t

INCLUDES ///.

CFile****************************************************************

FileName [kit.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kit.h,v 1.00 2006/12/06 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 51 of file kit.h.

Enumeration Type Documentation

enum Kit_Dsd_t
Enumerator
KIT_DSD_NONE 
KIT_DSD_CONST1 
KIT_DSD_VAR 
KIT_DSD_AND 
KIT_DSD_XOR 
KIT_DSD_PRIME 

Definition at line 98 of file kit.h.

98  {
99  KIT_DSD_NONE = 0, // 0: unknown
100  KIT_DSD_CONST1, // 1: constant 1
101  KIT_DSD_VAR, // 2: elementary variable
102  KIT_DSD_AND, // 3: multi-input AND
103  KIT_DSD_XOR, // 4: multi-input XOR
104  KIT_DSD_PRIME // 5: arbitrary function of 3+ variables
105 } Kit_Dsd_t;
Kit_Dsd_t
Definition: kit.h:98

Function Documentation

static unsigned Kit_BitMask ( int  nBits)
inlinestatic

Definition at line 225 of file kit.h.

225 { assert( nBits <= 32 ); return ~((~(unsigned)0) << nBits); }
#define assert(ex)
Definition: util_old.h:213
static int Kit_BitWordNum ( int  nBits)
inlinestatic

Definition at line 223 of file kit.h.

223 { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); }
unsigned* Kit_CloudToTruth ( Vec_Int_t vNodes,
int  nVars,
Vec_Ptr_t vStore,
int  fInv 
)

Function*************************************************************

Synopsis [Computes composition of truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file kitCloud.c.

230 {
231  unsigned * pThis, * pFan0, * pFan1;
232  Kit_Mux_t Mux;
233  int i, Entry;
234  assert( Vec_IntSize(vNodes) <= Vec_PtrSize(vStore) );
235  pThis = (unsigned *)Vec_PtrEntry( vStore, 0 );
236  Kit_TruthFill( pThis, nVars );
237  Vec_IntForEachEntryStart( vNodes, Entry, i, 1 )
238  {
239  Mux = Kit_Int2Mux(Entry);
240  assert( (int)Mux.e < i && (int)Mux.t < i && (int)Mux.v < nVars );
241  pFan0 = (unsigned *)Vec_PtrEntry( vStore, Mux.e );
242  pFan1 = (unsigned *)Vec_PtrEntry( vStore, Mux.t );
243  pThis = (unsigned *)Vec_PtrEntry( vStore, i );
244  Kit_TruthMuxVarPhase( pThis, pFan0, pFan1, nVars, fInv? Mux.v : nVars-1-Mux.v, Mux.c );
245  }
246  // complement the result
247  if ( Mux.i )
248  Kit_TruthNot( pThis, pThis, nVars );
249  return pThis;
250 }
static void Kit_TruthFill(unsigned *pOut, int nVars)
Definition: kit.h:367
void Kit_TruthMuxVarPhase(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar, int fCompl0)
Definition: kitTruth.c:1125
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
typedefABC_NAMESPACE_IMPL_START struct Kit_Mux_t_ Kit_Mux_t
DECLARATIONS ///.
Definition: kitCloud.c:31
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Kit_Mux_t Kit_Int2Mux(int m)
Definition: kitCloud.c:42
#define assert(ex)
Definition: util_old.h:213
int Kit_CreateCloud ( CloudManager dd,
CloudNode pFunc,
Vec_Int_t vNodes 
)

Function********************************************************************

Synopsis [Transforms the array of BDDs into the integer array.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file kitCloud.c.

168 {
169  Kit_Mux_t Mux;
170  int nNodes, i;
171  // collect BDD nodes
172  nNodes = Cloud_DagCollect( dd, pFunc );
173  if ( nNodes >= (1<<12) ) // because in Kit_Mux_t edge is 12 bit
174  return 0;
175  assert( nNodes == Cloud_DagSize( dd, pFunc ) );
176  assert( nNodes < dd->nNodesLimit );
177  Vec_IntClear( vNodes );
178  Vec_IntPush( vNodes, 0 ); // const1 node
179  dd->ppNodes[0]->s = 0;
180  for ( i = 1; i < nNodes; i++ )
181  {
182  dd->ppNodes[i]->s = i;
183  Mux.v = dd->ppNodes[i]->v;
184  Mux.t = dd->ppNodes[i]->t->s;
185  Mux.e = Cloud_Regular(dd->ppNodes[i]->e)->s;
186  Mux.c = Cloud_IsComplement(dd->ppNodes[i]->e);
187  Mux.i = (i == nNodes - 1)? Cloud_IsComplement(pFunc) : 0;
188  // put the MUX into the array
189  Vec_IntPush( vNodes, Kit_Mux2Int(Mux) );
190  }
191  assert( Vec_IntSize(vNodes) == nNodes );
192  // reset signatures
193  for ( i = 0; i < nNodes; i++ )
194  dd->ppNodes[i]->s = dd->nSignCur;
195  return 1;
196 }
#define Cloud_IsComplement(p)
Definition: cloud.h:188
#define Cloud_Regular(p)
Definition: cloud.h:185
typedefABC_NAMESPACE_IMPL_START struct Kit_Mux_t_ Kit_Mux_t
DECLARATIONS ///.
Definition: kitCloud.c:31
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Kit_Mux2Int(Kit_Mux_t m)
Definition: kitCloud.c:41
int Cloud_DagSize(CloudManager *dd, CloudNode *n)
Definition: cloud.c:721
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Cloud_DagCollect(CloudManager *dd, CloudNode *n)
Definition: cloud.c:772
int Kit_CreateCloudFromTruth ( CloudManager dd,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vNodes 
)

Function********************************************************************

Synopsis [Transforms the array of BDDs into the integer array.]

Description []

SideEffects []

SeeAlso []

Definition at line 209 of file kitCloud.c.

210 {
211  CloudNode * pFunc;
212  Cloud_Restart( dd );
213  pFunc = Kit_TruthToCloud( dd, pTruth, nVars );
214  Vec_IntClear( vNodes );
215  return Kit_CreateCloud( dd, pFunc, vNodes );
216 }
int Kit_CreateCloud(CloudManager *dd, CloudNode *pFunc, Vec_Int_t *vNodes)
Definition: kitCloud.c:167
void Cloud_Restart(CloudManager *dd)
Definition: cloud.c:166
CloudNode * Kit_TruthToCloud(CloudManager *dd, unsigned *pTruth, int nVars)
Definition: kitCloud.c:148
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Kit_CubeContains ( unsigned  uLarge,
unsigned  uSmall 
)
inlinestatic

Definition at line 180 of file kit.h.

180 { return (uLarge & uSmall) == uSmall; }
static int Kit_CubeHasLit ( unsigned  uCube,
int  i 
)
inlinestatic

Definition at line 175 of file kit.h.

175 { return(uCube & (unsigned)(1<<i)) > 0; }
static int Kit_CubeIsMarked ( unsigned  uCube)
inlinestatic

Definition at line 184 of file kit.h.

184 { return Kit_CubeHasLit( uCube, 31 ); }
static int Kit_CubeHasLit(unsigned uCube, int i)
Definition: kit.h:175
static unsigned Kit_CubeMark ( unsigned  uCube)
inlinestatic

Definition at line 185 of file kit.h.

185 { return Kit_CubeSetLit( uCube, 31 ); }
static unsigned Kit_CubeSetLit(unsigned uCube, int i)
Definition: kit.h:176
static unsigned Kit_CubeMask ( int  nVar)
inlinestatic

Definition at line 182 of file kit.h.

182 { return (~(unsigned)0) >> (32-nVar); }
static unsigned Kit_CubeRemLit ( unsigned  uCube,
int  i 
)
inlinestatic

Definition at line 178 of file kit.h.

178 { return uCube & ~(unsigned)(1<<i); }
static unsigned Kit_CubeSetLit ( unsigned  uCube,
int  i 
)
inlinestatic

Definition at line 176 of file kit.h.

176 { return uCube | (unsigned)(1<<i); }
static unsigned Kit_CubeSharp ( unsigned  uCube,
unsigned  uMask 
)
inlinestatic

Definition at line 181 of file kit.h.

181 { return uCube & ~uMask; }
static unsigned Kit_CubeUnmark ( unsigned  uCube)
inlinestatic

Definition at line 186 of file kit.h.

186 { return Kit_CubeRemLit( uCube, 31 ); }
static unsigned Kit_CubeRemLit(unsigned uCube, int i)
Definition: kit.h:178
static unsigned Kit_CubeXorLit ( unsigned  uCube,
int  i 
)
inlinestatic

Definition at line 177 of file kit.h.

177 { return uCube ^ (unsigned)(1<<i); }
int Kit_DsdCofactoring ( unsigned *  pTruth,
int  nVars,
int *  pCofVars,
int  nLimit,
int  fVerbose 
)

Function*************************************************************

Synopsis [Canonical decomposition into completely DSD-structure.]

Description [Returns the number of cofactoring steps. Also returns the cofactoring variables in pVars.]

SideEffects []

SeeAlso []

Definition at line 2678 of file kitDsd.c.

2679 {
2680  Kit_DsdNtk_t * ppNtks[5][16] = {
2681  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
2682  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
2683  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
2684  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
2685  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
2686  };
2687  Kit_DsdNtk_t * pTemp;
2688  unsigned * ppCofs[5][16];
2689  int pTryVars[16], nTryVars;
2690  int nPrimeSizeMin, nPrimeSizeMax, nPrimeSizeCur;
2691  int nSuppSizeMin, nSuppSizeMax, iVarBest;
2692  int i, k, v, nStep, nSize, nMemSize;
2693  assert( nLimit < 5 );
2694 
2695  // allocate storage for cofactors
2696  nMemSize = Kit_TruthWordNum(nVars);
2697  ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize );
2698  nSize = 0;
2699  for ( i = 0; i < 5; i++ )
2700  for ( k = 0; k < 16; k++ )
2701  ppCofs[i][k] = ppCofs[0][0] + nMemSize * nSize++;
2702  assert( nSize == 80 );
2703 
2704  // copy the function
2705  Kit_TruthCopy( ppCofs[0][0], pTruth, nVars );
2706  ppNtks[0][0] = Kit_DsdDecompose( ppCofs[0][0], nVars );
2707 
2708  if ( fVerbose )
2709  printf( "\nProcessing prime function with %d support variables:\n", nVars );
2710 
2711  // perform recursive cofactoring
2712  for ( nStep = 0; nStep < nLimit; nStep++ )
2713  {
2714  nSize = (1 << nStep);
2715  // find the variables to use in the cofactoring step
2716  nTryVars = Kit_DsdCofactoringGetVars( ppNtks[nStep], nSize, pTryVars );
2717  if ( nTryVars == 0 )
2718  break;
2719  // cofactor w.r.t. the above variables
2720  iVarBest = -1;
2721  nPrimeSizeMin = 10000;
2722  nSuppSizeMin = 10000;
2723  for ( v = 0; v < nTryVars; v++ )
2724  {
2725  nPrimeSizeMax = 0;
2726  nSuppSizeMax = 0;
2727  for ( i = 0; i < nSize; i++ )
2728  {
2729  // cofactor and decompose cofactors
2730  Kit_TruthCofactor0New( ppCofs[nStep+1][2*i+0], ppCofs[nStep][i], nVars, pTryVars[v] );
2731  Kit_TruthCofactor1New( ppCofs[nStep+1][2*i+1], ppCofs[nStep][i], nVars, pTryVars[v] );
2732  ppNtks[nStep+1][2*i+0] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+0], nVars );
2733  ppNtks[nStep+1][2*i+1] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+1], nVars );
2734  // compute the largest non-decomp block
2735  nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[nStep+1][2*i+0]);
2736  nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
2737  nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[nStep+1][2*i+1]);
2738  nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
2739  // compute the sum total of supports
2740  nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+0], nVars );
2741  nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+1], nVars );
2742  // free the networks
2743  Kit_DsdNtkFree( ppNtks[nStep+1][2*i+0] );
2744  Kit_DsdNtkFree( ppNtks[nStep+1][2*i+1] );
2745  }
2746  // find the min max support size of the prime component
2747  if ( nPrimeSizeMin > nPrimeSizeMax || (nPrimeSizeMin == nPrimeSizeMax && nSuppSizeMin > nSuppSizeMax) )
2748  {
2749  nPrimeSizeMin = nPrimeSizeMax;
2750  nSuppSizeMin = nSuppSizeMax;
2751  iVarBest = pTryVars[v];
2752  }
2753  }
2754  assert( iVarBest != -1 );
2755  // save the variable
2756  if ( pCofVars )
2757  pCofVars[nStep] = iVarBest;
2758  // cofactor w.r.t. the best
2759  for ( i = 0; i < nSize; i++ )
2760  {
2761  Kit_TruthCofactor0New( ppCofs[nStep+1][2*i+0], ppCofs[nStep][i], nVars, iVarBest );
2762  Kit_TruthCofactor1New( ppCofs[nStep+1][2*i+1], ppCofs[nStep][i], nVars, iVarBest );
2763  ppNtks[nStep+1][2*i+0] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+0], nVars );
2764  ppNtks[nStep+1][2*i+1] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+1], nVars );
2765  if ( fVerbose )
2766  {
2767  ppNtks[nStep+1][2*i+0] = Kit_DsdExpand( pTemp = ppNtks[nStep+1][2*i+0] );
2768  Kit_DsdNtkFree( pTemp );
2769  ppNtks[nStep+1][2*i+1] = Kit_DsdExpand( pTemp = ppNtks[nStep+1][2*i+1] );
2770  Kit_DsdNtkFree( pTemp );
2771 
2772  printf( "Cof%d%d: ", nStep+1, 2*i+0 );
2773  Kit_DsdPrint( stdout, ppNtks[nStep+1][2*i+0] ), printf( "\n" );
2774  printf( "Cof%d%d: ", nStep+1, 2*i+1 );
2775  Kit_DsdPrint( stdout, ppNtks[nStep+1][2*i+1] ), printf( "\n" );
2776  }
2777  }
2778  }
2779 
2780  // free the networks
2781  for ( i = 0; i < 5; i++ )
2782  for ( k = 0; k < 16; k++ )
2783  if ( ppNtks[i][k] )
2784  Kit_DsdNtkFree( ppNtks[i][k] );
2785  ABC_FREE( ppCofs[0][0] );
2786 
2787  assert( nStep <= nLimit );
2788  return nStep;
2789 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
#define KIT_MAX(a, b)
Definition: kit.h:172
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
Definition: kitDsd.c:2314
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
int Kit_DsdCofactoringGetVars(Kit_DsdNtk_t **ppNtk, int nSize, int *pVars)
Definition: kitDsd.c:2632
int Kit_DsdNonDsdSizeMax(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1211
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
#define assert(ex)
Definition: util_old.h:213
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
Definition: kitTruth.c:327
int Kit_DsdCountAigNodes ( Kit_DsdNtk_t pNtk)

Function*************************************************************

Synopsis [Returns 1 if there is a component with more than 3 inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1895 of file kitDsd.c.

1896 {
1897  Kit_DsdObj_t * pObj;
1898  int i, Counter = 0;
1899  for ( i = 0; i < pNtk->nNodes; i++ )
1900  {
1901  pObj = pNtk->pNodes[i];
1902  if ( pObj->Type == KIT_DSD_AND )
1903  Counter += ((int)pObj->nFans - 1);
1904  else if ( pObj->Type == KIT_DSD_XOR )
1905  Counter += ((int)pObj->nFans - 1) * 3;
1906  else if ( pObj->Type == KIT_DSD_PRIME ) // assuming MUX decomposition
1907  Counter += 3;
1908  }
1909  return Counter;
1910 }
unsigned Type
Definition: kit.h:112
unsigned nFans
Definition: kit.h:116
Kit_DsdObj_t ** pNodes
Definition: kit.h:130
static int Counter
unsigned short nNodes
Definition: kit.h:126
Kit_DsdNtk_t* Kit_DsdDecompose ( unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Performs decomposition of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 2314 of file kitDsd.c.

2315 {
2316  return Kit_DsdDecomposeInt( pTruth, nVars, 0 );
2317 }
Kit_DsdNtk_t * Kit_DsdDecomposeInt(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2266
Kit_DsdNtk_t* Kit_DsdDecomposeExpand ( unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Performs decomposition of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 2330 of file kitDsd.c.

2331 {
2332  Kit_DsdNtk_t * pNtk, * pTemp;
2333  pNtk = Kit_DsdDecomposeInt( pTruth, nVars, 0 );
2334  pNtk = Kit_DsdExpand( pTemp = pNtk );
2335  Kit_DsdNtkFree( pTemp );
2336  return pNtk;
2337 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
Kit_DsdNtk_t * Kit_DsdDecomposeInt(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2266
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
Kit_DsdNtk_t* Kit_DsdDecomposeMux ( unsigned *  pTruth,
int  nVars,
int  nDecMux 
)

Function*************************************************************

Synopsis [Performs decomposition of the truth table.]

Description [Uses MUXes to break-down large prime nodes.]

SideEffects []

SeeAlso []

Definition at line 2350 of file kitDsd.c.

2351 {
2352 /*
2353  Kit_DsdNtk_t * pNew;
2354  Kit_DsdObj_t * pObjNew;
2355  assert( nVars <= 16 );
2356  // create a new network
2357  pNew = Kit_DsdNtkAlloc( nVars );
2358  // consider simple special cases
2359  if ( nVars == 0 )
2360  {
2361  pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
2362  pNew->Root = Abc_Var2Lit( pObjNew->Id, (int)(pTruth[0] == 0) );
2363  return pNew;
2364  }
2365  if ( nVars == 1 )
2366  {
2367  pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
2368  pObjNew->pFans[0] = Abc_Var2Lit( 0, 0 );
2369  pNew->Root = Abc_Var2Lit( pObjNew->Id, (int)(pTruth[0] != 0xAAAAAAAA) );
2370  return pNew;
2371  }
2372 */
2373  return Kit_DsdDecomposeInt( pTruth, nVars, nDecMux );
2374 }
Kit_DsdNtk_t * Kit_DsdDecomposeInt(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2266
Kit_DsdNtk_t* Kit_DsdDeriveNtk ( unsigned *  pTruth,
int  nVars,
int  nLutSize 
)
Kit_DsdNtk_t* Kit_DsdExpand ( Kit_DsdNtk_t p)

Function*************************************************************

Synopsis [Expands the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1451 of file kitDsd.c.

1452 {
1453  Kit_DsdNtk_t * pNew;
1454  Kit_DsdObj_t * pObjNew;
1455  assert( p->nVars <= 16 );
1456  // create a new network
1457  pNew = Kit_DsdNtkAlloc( p->nVars );
1458  // consider simple special cases
1459  if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_CONST1 )
1460  {
1461  pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
1462  pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1463  return pNew;
1464  }
1465  if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_VAR )
1466  {
1467  pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
1468  pObjNew->pFans[0] = Kit_DsdNtkRoot(p)->pFans[0];
1469  pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1470  return pNew;
1471  }
1472  // convert the root node
1473  pNew->Root = Kit_DsdExpandNode_rec( pNew, p, p->Root );
1474  return pNew;
1475 }
static Kit_DsdObj_t * Kit_DsdNtkRoot(Kit_DsdNtk_t *pNtk)
Definition: kit.h:151
int Kit_DsdExpandNode_rec(Kit_DsdNtk_t *pNew, Kit_DsdNtk_t *p, int iLit)
Definition: kitDsd.c:1349
Kit_DsdNtk_t * Kit_DsdNtkAlloc(int nVars)
Definition: kitDsd.c:140
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
unsigned short Root
Definition: kit.h:127
unsigned Id
Definition: kit.h:111
Kit_DsdObj_t * Kit_DsdObjAlloc(Kit_DsdNtk_t *pNtk, Kit_Dsd_t Type, int nFans)
Definition: kitDsd.c:92
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned short pFans[0]
Definition: kit.h:117
#define assert(ex)
Definition: util_old.h:213
unsigned short nVars
Definition: kit.h:124
unsigned Kit_DsdGetSupports ( Kit_DsdNtk_t p)

Function*************************************************************

Synopsis [Compute the support.]

Description []

SideEffects []

SeeAlso []

Definition at line 1762 of file kitDsd.c.

1763 {
1764  Kit_DsdObj_t * pRoot;
1765  unsigned uSupport;
1766  assert( p->pSupps == NULL );
1767  p->pSupps = ABC_ALLOC( unsigned, p->nNodes );
1768  // consider simple special cases
1769  pRoot = Kit_DsdNtkRoot(p);
1770  if ( pRoot->Type == KIT_DSD_CONST1 )
1771  {
1772  assert( p->nNodes == 1 );
1773  uSupport = p->pSupps[0] = 0;
1774  }
1775  if ( pRoot->Type == KIT_DSD_VAR )
1776  {
1777  assert( p->nNodes == 1 );
1778  uSupport = p->pSupps[0] = Kit_DsdLitSupport( p, pRoot->pFans[0] );
1779  }
1780  else
1781  uSupport = Kit_DsdGetSupports_rec( p, p->Root );
1782  assert( uSupport <= 0xFFFF );
1783  return uSupport;
1784 }
unsigned Type
Definition: kit.h:112
static Kit_DsdObj_t * Kit_DsdNtkRoot(Kit_DsdNtk_t *pNtk)
Definition: kit.h:151
unsigned short Root
Definition: kit.h:127
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned * pSupps
Definition: kit.h:129
unsigned short pFans[0]
Definition: kit.h:117
unsigned Kit_DsdGetSupports_rec(Kit_DsdNtk_t *p, int iLit)
Definition: kitDsd.c:1735
unsigned short nNodes
Definition: kit.h:126
#define assert(ex)
Definition: util_old.h:213
static unsigned Kit_DsdLitSupport(Kit_DsdNtk_t *pNtk, int Lit)
Definition: kit.h:153
static int Kit_DsdLitIsLeaf ( Kit_DsdNtk_t pNtk,
int  Lit 
)
inlinestatic

Definition at line 152 of file kit.h.

152 { int Id = Abc_Lit2Var(Lit); assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars; }
unsigned short nNodes
Definition: kit.h:126
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
unsigned short nVars
Definition: kit.h:124
static unsigned Kit_DsdLitSupport ( Kit_DsdNtk_t pNtk,
int  Lit 
)
inlinestatic

Definition at line 153 of file kit.h.

153 { int Id = Abc_Lit2Var(Lit); assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return pNtk->pSupps? (Id < pNtk->nVars? (1 << Id) : pNtk->pSupps[Id - pNtk->nVars]) : 0; }
unsigned * pSupps
Definition: kit.h:129
unsigned short nNodes
Definition: kit.h:126
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
unsigned short nVars
Definition: kit.h:124
Kit_DsdMan_t* Kit_DsdManAlloc ( int  nVars,
int  nNodes 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [kitDsd.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Performs disjoint-support decomposition based on truth tables.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitDsd.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Allocates the DSD manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file kitDsd.c.

46 {
47  Kit_DsdMan_t * p;
48  p = ABC_ALLOC( Kit_DsdMan_t, 1 );
49  memset( p, 0, sizeof(Kit_DsdMan_t) );
50  p->nVars = nVars;
51  p->nWords = Kit_TruthWordNum( p->nVars );
53  p->vTtNodes = Vec_PtrAllocSimInfo( nNodes, p->nWords );
54  p->dd = Cloud_Init( 16, 14 );
55  p->vTtBdds = Vec_PtrAllocSimInfo( (1<<12), p->nWords );
56  p->vNodes = Vec_IntAlloc( 512 );
57  return p;
58 }
char * memset()
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
CloudManager * Cloud_Init(int nVars, int nBits)
FUNCTION DEFINITIONS ///.
Definition: cloud.c:70
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nVars
Definition: kit.h:137
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Ptr_t * vTtBdds
Definition: kit.h:143
Vec_Ptr_t * vTtElems
Definition: kit.h:139
CloudManager * dd
Definition: kit.h:142
Vec_Int_t * vNodes
Definition: kit.h:144
Vec_Ptr_t * vTtNodes
Definition: kit.h:140
int nWords
Definition: kit.h:138
static Vec_Ptr_t * Vec_PtrAllocSimInfo(int nEntries, int nWords)
Definition: vecPtr.h:929
void Kit_DsdManFree ( Kit_DsdMan_t p)

Function*************************************************************

Synopsis [Deallocates the DSD manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file kitDsd.c.

72 {
73  Cloud_Quit( p->dd );
74  Vec_IntFree( p->vNodes );
75  Vec_PtrFree( p->vTtBdds );
76  Vec_PtrFree( p->vTtElems );
77  Vec_PtrFree( p->vTtNodes );
78  ABC_FREE( p );
79 }
void Cloud_Quit(CloudManager *dd)
Definition: cloud.c:144
Vec_Ptr_t * vTtBdds
Definition: kit.h:143
Vec_Ptr_t * vTtElems
Definition: kit.h:139
CloudManager * dd
Definition: kit.h:142
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Int_t * vNodes
Definition: kit.h:144
Vec_Ptr_t * vTtNodes
Definition: kit.h:140
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Kit_DsdObj_t* Kit_DsdNonDsdPrimeMax ( Kit_DsdNtk_t pNtk)

Function*************************************************************

Synopsis [Returns the largest non-DSD block.]

Description []

SideEffects []

SeeAlso []

Definition at line 1236 of file kitDsd.c.

1237 {
1238  Kit_DsdObj_t * pObj, * pObjMax = NULL;
1239  unsigned i, nSizeMax = 0;
1240  Kit_DsdNtkForEachObj( pNtk, pObj, i )
1241  {
1242  if ( pObj->Type != KIT_DSD_PRIME )
1243  continue;
1244  if ( nSizeMax < pObj->nFans )
1245  {
1246  nSizeMax = pObj->nFans;
1247  pObjMax = pObj;
1248  }
1249  }
1250  return pObjMax;
1251 }
unsigned Type
Definition: kit.h:112
unsigned nFans
Definition: kit.h:116
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
Definition: kit.h:155
int Kit_DsdNonDsdSizeMax ( Kit_DsdNtk_t pNtk)

Function*************************************************************

Synopsis [Returns the size of the largest non-DSD block.]

Description []

SideEffects []

SeeAlso []

Definition at line 1211 of file kitDsd.c.

1212 {
1213  Kit_DsdObj_t * pObj;
1214  unsigned i, nSizeMax = 0;
1215  Kit_DsdNtkForEachObj( pNtk, pObj, i )
1216  {
1217  if ( pObj->Type != KIT_DSD_PRIME )
1218  continue;
1219  if ( nSizeMax < pObj->nFans )
1220  nSizeMax = pObj->nFans;
1221  }
1222  return nSizeMax;
1223 }
unsigned Type
Definition: kit.h:112
unsigned nFans
Definition: kit.h:116
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
Definition: kit.h:155
unsigned Kit_DsdNonDsdSupports ( Kit_DsdNtk_t pNtk)

Function*************************************************************

Synopsis [Finds the union of supports of the non-DSD blocks.]

Description []

SideEffects []

SeeAlso []

Definition at line 1264 of file kitDsd.c.

1265 {
1266  Kit_DsdObj_t * pObj;
1267  unsigned i, uSupport = 0;
1268 // ABC_FREE( pNtk->pSupps );
1269  Kit_DsdGetSupports( pNtk );
1270  Kit_DsdNtkForEachObj( pNtk, pObj, i )
1271  {
1272  if ( pObj->Type != KIT_DSD_PRIME )
1273  continue;
1274  uSupport |= Kit_DsdLitSupport( pNtk, Abc_Var2Lit(pObj->Id,0) );
1275  }
1276  return uSupport;
1277 }
unsigned Type
Definition: kit.h:112
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
unsigned Id
Definition: kit.h:111
unsigned Kit_DsdGetSupports(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1762
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
Definition: kit.h:155
static unsigned Kit_DsdLitSupport(Kit_DsdNtk_t *pNtk, int Lit)
Definition: kit.h:153
void Kit_DsdNtkFree ( Kit_DsdNtk_t pNtk)

Function*************************************************************

Synopsis [Deallocate the DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file kitDsd.c.

164 {
165  Kit_DsdObj_t * pObj;
166  unsigned i;
167  Kit_DsdNtkForEachObj( pNtk, pObj, i )
168  ABC_FREE( pObj );
169  ABC_FREE( pNtk->pSupps );
170  ABC_FREE( pNtk->pNodes );
171  ABC_FREE( pNtk->pMem );
172  ABC_FREE( pNtk );
173 }
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
Definition: kit.h:155
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int * pSupps
Definition: abcUtil.c:2053
static Kit_DsdObj_t* Kit_DsdNtkObj ( Kit_DsdNtk_t pNtk,
int  Id 
)
inlinestatic

Definition at line 150 of file kit.h.

150 { assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars ? NULL : pNtk->pNodes[Id - pNtk->nVars]; }
Kit_DsdObj_t ** pNodes
Definition: kit.h:130
unsigned short nNodes
Definition: kit.h:126
#define assert(ex)
Definition: util_old.h:213
unsigned short nVars
Definition: kit.h:124
static int Kit_DsdNtkObjNum ( Kit_DsdNtk_t pNtk)
inlinestatic

Definition at line 149 of file kit.h.

149 { return pNtk->nVars + pNtk->nNodes; }
unsigned short nNodes
Definition: kit.h:126
unsigned short nVars
Definition: kit.h:124
static Kit_DsdObj_t* Kit_DsdNtkRoot ( Kit_DsdNtk_t pNtk)
inlinestatic

Definition at line 151 of file kit.h.

151 { return Kit_DsdNtkObj( pNtk, Abc_Lit2Var(pNtk->Root) ); }
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
Definition: kit.h:150
unsigned short Root
Definition: kit.h:127
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static unsigned Kit_DsdObjOffset ( int  nFans)
inlinestatic

Definition at line 147 of file kit.h.

147 { return (nFans >> 1) + ((nFans & 1) > 0); }
static unsigned* Kit_DsdObjTruth ( Kit_DsdObj_t pObj)
inlinestatic

Definition at line 148 of file kit.h.

148 { return pObj->Type == KIT_DSD_PRIME ? (unsigned *)pObj->pFans + pObj->Offset: NULL; }
unsigned Type
Definition: kit.h:112
unsigned Offset
Definition: kit.h:114
unsigned short pFans[0]
Definition: kit.h:117
void Kit_DsdPrint ( FILE *  pFile,
Kit_DsdNtk_t pNtk 
)

Function*************************************************************

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 374 of file kitDsd.c.

375 {
376  fprintf( pFile, "F = " );
377  if ( Abc_LitIsCompl(pNtk->Root) )
378  fprintf( pFile, "!" );
379  Kit_DsdPrint_rec( pFile, pNtk, Abc_Lit2Var(pNtk->Root) );
380 // fprintf( pFile, "\n" );
381 }
unsigned short Root
Definition: kit.h:127
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
void Kit_DsdPrint_rec(FILE *pFile, Kit_DsdNtk_t *pNtk, int Id)
Definition: kitDsd.c:317
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
void Kit_DsdPrintExpanded ( Kit_DsdNtk_t pNtk)

Function*************************************************************

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 471 of file kitDsd.c.

472 {
473  Kit_DsdNtk_t * pTemp;
474  pTemp = Kit_DsdExpand( pNtk );
475  Kit_DsdPrint( stdout, pTemp );
476  Kit_DsdNtkFree( pTemp );
477 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
void Kit_DsdPrintFromTruth ( unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 490 of file kitDsd.c.

491 {
492  Kit_DsdNtk_t * pTemp, * pTemp2;
493 // pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
494  pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
495 // Kit_DsdPrintExpanded( pTemp );
496  pTemp2 = Kit_DsdExpand( pTemp );
497  Kit_DsdPrint( stdout, pTemp2 );
498  Kit_DsdVerify( pTemp2, pTruth, nVars );
499  Kit_DsdNtkFree( pTemp2 );
500  Kit_DsdNtkFree( pTemp );
501 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350
void Kit_DsdPrintFromTruth2 ( FILE *  pFile,
unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 514 of file kitDsd.c.

515 {
516  Kit_DsdNtk_t * pTemp, * pTemp2;
517  pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 0 );
518  pTemp2 = Kit_DsdExpand( pTemp );
519  Kit_DsdPrint2( pFile, pTemp2 );
520  Kit_DsdVerify( pTemp2, pTruth, nVars );
521  Kit_DsdNtkFree( pTemp2 );
522  Kit_DsdNtkFree( pTemp );
523 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
void Kit_DsdPrint2(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:297
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350
void Kit_DsdRotate ( Kit_DsdNtk_t p,
int  pFreqs[] 
)

Function*************************************************************

Synopsis [Rotates the network.]

Description [Transforms prime nodes to have the fanin with the highest frequency of supports go first.]

SideEffects []

SeeAlso []

Definition at line 1671 of file kitDsd.c.

1672 {
1673  Kit_DsdObj_t * pObj;
1674  unsigned * pIn, * pOut, * pTemp, k;
1675  int i, v, Temp, uSuppFanin, iFaninLit, WeightMax, FaninMax, nSwaps;
1676  int Weights[16];
1677  // go through the prime nodes
1678  Kit_DsdNtkForEachObj( p, pObj, i )
1679  {
1680  if ( pObj->Type != KIT_DSD_PRIME )
1681  continue;
1682  // count the fanin frequencies
1683  Kit_DsdObjForEachFanin( p, pObj, iFaninLit, k )
1684  {
1685  uSuppFanin = Kit_DsdLitSupport( p, iFaninLit );
1686  Weights[k] = 0;
1687  for ( v = 0; v < 16; v++ )
1688  if ( uSuppFanin & (1 << v) )
1689  Weights[k] += pFreqs[v] - 1;
1690  }
1691  // find the most frequent fanin
1692  WeightMax = 0;
1693  FaninMax = -1;
1694  for ( k = 0; k < pObj->nFans; k++ )
1695  if ( WeightMax < Weights[k] )
1696  {
1697  WeightMax = Weights[k];
1698  FaninMax = k;
1699  }
1700  // no need to reorder if there are no frequent fanins
1701  if ( FaninMax == -1 )
1702  continue;
1703  // move the fanins number k to the first place
1704  nSwaps = 0;
1705  pIn = Kit_DsdObjTruth(pObj);
1706  pOut = p->pMem;
1707 // for ( v = FaninMax; v < ((int)pObj->nFans)-1; v++ )
1708  for ( v = FaninMax-1; v >= 0; v-- )
1709  {
1710  // swap the fanins
1711  Temp = pObj->pFans[v];
1712  pObj->pFans[v] = pObj->pFans[v+1];
1713  pObj->pFans[v+1] = Temp;
1714  // swap the truth table variables
1715  Kit_TruthSwapAdjacentVars( pOut, pIn, pObj->nFans, v );
1716  pTemp = pIn; pIn = pOut; pOut = pTemp;
1717  nSwaps++;
1718  }
1719  if ( nSwaps & 1 )
1720  Kit_TruthCopy( pOut, pIn, pObj->nFans );
1721  }
1722 }
unsigned Type
Definition: kit.h:112
static int pFreqs[13719]
Definition: rwrTemp.c:31
void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int Start)
DECLARATIONS ///.
Definition: kitTruth.c:46
unsigned nFans
Definition: kit.h:116
unsigned * pMem
Definition: kit.h:128
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
Definition: kit.h:157
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
Definition: kit.h:155
static unsigned * Kit_DsdObjTruth(Kit_DsdObj_t *pObj)
Definition: kit.h:148
unsigned short pFans[0]
Definition: kit.h:117
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static unsigned Kit_DsdLitSupport(Kit_DsdNtk_t *pNtk, int Lit)
Definition: kit.h:153
Kit_DsdNtk_t* Kit_DsdShrink ( Kit_DsdNtk_t p,
int  pPrios[] 
)

Function*************************************************************

Synopsis [Shrinks the network.]

Description [Transforms the network to have two-input nodes so that the higher-ordered nodes were decomposed out first.]

SideEffects []

SeeAlso []

Definition at line 1633 of file kitDsd.c.

1634 {
1635  Kit_DsdNtk_t * pNew;
1636  Kit_DsdObj_t * pObjNew;
1637  assert( p->nVars <= 16 );
1638  // create a new network
1639  pNew = Kit_DsdNtkAlloc( p->nVars );
1640  // consider simple special cases
1641  if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_CONST1 )
1642  {
1643  pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
1644  pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1645  return pNew;
1646  }
1647  if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_VAR )
1648  {
1649  pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
1650  pObjNew->pFans[0] = Kit_DsdNtkRoot(p)->pFans[0];
1651  pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1652  return pNew;
1653  }
1654  // convert the root node
1655  pNew->Root = Kit_DsdShrink_rec( pNew, p, p->Root, pPrios );
1656  return pNew;
1657 }
static Kit_DsdObj_t * Kit_DsdNtkRoot(Kit_DsdNtk_t *pNtk)
Definition: kit.h:151
int Kit_DsdShrink_rec(Kit_DsdNtk_t *pNew, Kit_DsdNtk_t *p, int iLit, int pPrios[])
Definition: kitDsd.c:1543
Kit_DsdNtk_t * Kit_DsdNtkAlloc(int nVars)
Definition: kitDsd.c:140
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
unsigned short Root
Definition: kit.h:127
unsigned Id
Definition: kit.h:111
Kit_DsdObj_t * Kit_DsdObjAlloc(Kit_DsdNtk_t *pNtk, Kit_Dsd_t Type, int nFans)
Definition: kitDsd.c:92
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
unsigned short pFans[0]
Definition: kit.h:117
#define assert(ex)
Definition: util_old.h:213
unsigned short nVars
Definition: kit.h:124
void Kit_DsdTruth ( Kit_DsdNtk_t pNtk,
unsigned *  pTruthRes 
)

Function*************************************************************

Synopsis [Derives the truth table of the DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1068 of file kitDsd.c.

1069 {
1070  Kit_DsdMan_t * p;
1071  unsigned * pTruth;
1072  p = Kit_DsdManAlloc( pNtk->nVars, Kit_DsdNtkObjNum(pNtk) );
1073  pTruth = Kit_DsdTruthCompute( p, pNtk );
1074  Kit_TruthCopy( pTruthRes, pTruth, pNtk->nVars );
1075  Kit_DsdManFree( p );
1076 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned * Kit_DsdTruthCompute(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:663
void Kit_DsdManFree(Kit_DsdMan_t *p)
Definition: kitDsd.c:71
ABC_NAMESPACE_IMPL_START Kit_DsdMan_t * Kit_DsdManAlloc(int nVars, int nNodes)
DECLARATIONS ///.
Definition: kitDsd.c:45
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static int Kit_DsdNtkObjNum(Kit_DsdNtk_t *pNtk)
Definition: kit.h:149
unsigned short nVars
Definition: kit.h:124
unsigned* Kit_DsdTruthCompute ( Kit_DsdMan_t p,
Kit_DsdNtk_t pNtk 
)

Function*************************************************************

Synopsis [Derives the truth table of the DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 663 of file kitDsd.c.

664 {
665  unsigned * pTruthRes;
666  int i;
667  // assign elementary truth ables
668  assert( pNtk->nVars <= p->nVars );
669  for ( i = 0; i < (int)pNtk->nVars; i++ )
670  Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
671  // compute truth table for each node
672  pTruthRes = Kit_DsdTruthComputeNode_rec( p, pNtk, Abc_Lit2Var(pNtk->Root) );
673  // complement the truth table if needed
674  if ( Abc_LitIsCompl(pNtk->Root) )
675  Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
676  return pTruthRes;
677 }
int nVars
Definition: kit.h:137
unsigned short Root
Definition: kit.h:127
unsigned * Kit_DsdTruthComputeNode_rec(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, int Id)
Definition: kitDsd.c:560
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
Vec_Ptr_t * vTtElems
Definition: kit.h:139
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
Vec_Ptr_t * vTtNodes
Definition: kit.h:140
#define assert(ex)
Definition: util_old.h:213
unsigned short nVars
Definition: kit.h:124
void Kit_DsdTruthPartial ( Kit_DsdMan_t p,
Kit_DsdNtk_t pNtk,
unsigned *  pTruthRes,
unsigned  uSupp 
)

Function*************************************************************

Synopsis [Derives the truth table of the DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1107 of file kitDsd.c.

1108 {
1109  unsigned * pTruth = Kit_DsdTruthComputeOne( p, pNtk, uSupp );
1110  Kit_TruthCopy( pTruthRes, pTruth, pNtk->nVars );
1111 /*
1112  // verification
1113  {
1114  // compute the same function using different procedure
1115  unsigned * pTruthTemp = Vec_PtrEntry(p->vTtNodes, pNtk->nVars + pNtk->nNodes + 1);
1116  pNtk->pSupps = NULL;
1117  Kit_DsdTruthComputeTwo( p, pNtk, uSupp, -1, pTruthTemp );
1118 // if ( !Kit_TruthIsEqual( pTruthTemp, pTruthRes, pNtk->nVars ) )
1119  if ( !Kit_TruthIsEqualWithPhase( pTruthTemp, pTruthRes, pNtk->nVars ) )
1120  {
1121  printf( "Verification FAILED!\n" );
1122  Kit_DsdPrint( stdout, pNtk );
1123  Kit_DsdPrintFromTruth( pTruthRes, pNtk->nVars );
1124  Kit_DsdPrintFromTruth( pTruthTemp, pNtk->nVars );
1125  }
1126 // else
1127 // printf( "Verification successful.\n" );
1128  }
1129 */
1130 }
unsigned * Kit_DsdTruthComputeOne(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp)
Definition: kitDsd.c:823
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
unsigned short nVars
Definition: kit.h:124
void Kit_DsdTruthPartialTwo ( Kit_DsdMan_t p,
Kit_DsdNtk_t pNtk,
unsigned  uSupp,
int  iVar,
unsigned *  pTruthCo,
unsigned *  pTruthDec 
)

Function*************************************************************

Synopsis [Derives the truth table of the DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1089 of file kitDsd.c.

1090 {
1091  unsigned * pTruth = Kit_DsdTruthComputeTwo( p, pNtk, uSupp, iVar, pTruthDec );
1092  if ( pTruthCo )
1093  Kit_TruthCopy( pTruthCo, pTruth, pNtk->nVars );
1094 }
unsigned * Kit_DsdTruthComputeTwo(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp, int iVar, unsigned *pTruthDec)
Definition: kitDsd.c:1024
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
unsigned short nVars
Definition: kit.h:124
void Kit_DsdVerify ( Kit_DsdNtk_t pNtk,
unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Performs decomposition of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 2492 of file kitDsd.c.

2493 {
2494  Kit_DsdMan_t * p;
2495  unsigned * pTruthC;
2496  p = Kit_DsdManAlloc( nVars, Kit_DsdNtkObjNum(pNtk)+2 );
2497  pTruthC = Kit_DsdTruthCompute( p, pNtk );
2498  if ( !Extra_TruthIsEqual( pTruth, pTruthC, nVars ) )
2499  printf( "Verification failed.\n" );
2500  Kit_DsdManFree( p );
2501 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned * Kit_DsdTruthCompute(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:663
void Kit_DsdManFree(Kit_DsdMan_t *p)
Definition: kitDsd.c:71
ABC_NAMESPACE_IMPL_START Kit_DsdMan_t * Kit_DsdManAlloc(int nVars, int nNodes)
DECLARATIONS ///.
Definition: kitDsd.c:45
static int Extra_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: extra.h:270
static int Kit_DsdNtkObjNum(Kit_DsdNtk_t *pNtk)
Definition: kit.h:149
void Kit_DsdWriteFromTruth ( char *  pBuffer,
unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 536 of file kitDsd.c.

537 {
538  Kit_DsdNtk_t * pTemp, * pTemp2;
539 // pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
540  pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
541 // Kit_DsdPrintExpanded( pTemp );
542  pTemp2 = Kit_DsdExpand( pTemp );
543  Kit_DsdWrite( pBuffer, pTemp2 );
544  Kit_DsdVerify( pTemp2, pTruth, nVars );
545  Kit_DsdNtkFree( pTemp2 );
546  Kit_DsdNtkFree( pTemp );
547 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
void Kit_DsdWrite(char *pBuff, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:452
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350
static Kit_Edge_t Kit_EdgeCreate ( int  Node,
int  fCompl 
)
inlinestatic

Definition at line 194 of file kit.h.

194 { Kit_Edge_t eEdge = { fCompl, Node }; return eEdge; }
static unsigned Kit_EdgeToInt ( Kit_Edge_t  eEdge)
inlinestatic

Definition at line 195 of file kit.h.

195 { return (eEdge.Node << 1) | eEdge.fCompl; }
unsigned fCompl
Definition: kit.h:62
unsigned Node
Definition: kit.h:63
static unsigned Kit_EdgeToInt_ ( Kit_Edge_t  m)
inlinestatic

Definition at line 199 of file kit.h.

199 { union { Kit_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
Kit_Edge_t Kit_GraphAddNodeAnd ( Kit_Graph_t pGraph,
Kit_Edge_t  eEdge0,
Kit_Edge_t  eEdge1 
)

Function*************************************************************

Synopsis [Creates an AND node.]

Description []

SideEffects []

SeeAlso []

Definition at line 172 of file kitGraph.c.

173 {
174  Kit_Node_t * pNode;
175  // get the new node
176  pNode = Kit_GraphAppendNode( pGraph );
177  // set the inputs and other info
178  pNode->eEdge0 = eEdge0;
179  pNode->eEdge1 = eEdge1;
180  pNode->fCompl0 = eEdge0.fCompl;
181  pNode->fCompl1 = eEdge1.fCompl;
182  return Kit_EdgeCreate( pGraph->nSize - 1, 0 );
183 }
unsigned fCompl1
Definition: kit.h:78
Kit_Edge_t eEdge0
Definition: kit.h:69
unsigned fCompl0
Definition: kit.h:77
Kit_Edge_t eEdge1
Definition: kit.h:70
int nSize
Definition: kit.h:90
static Kit_Edge_t Kit_EdgeCreate(int Node, int fCompl)
Definition: kit.h:194
unsigned fCompl
Definition: kit.h:62
Kit_Node_t * Kit_GraphAppendNode(Kit_Graph_t *pGraph)
Definition: kitGraph.c:148
Kit_Edge_t Kit_GraphAddNodeMux ( Kit_Graph_t pGraph,
Kit_Edge_t  eEdgeC,
Kit_Edge_t  eEdgeT,
Kit_Edge_t  eEdgeE,
int  Type 
)

Function*************************************************************

Synopsis [Creates an XOR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 265 of file kitGraph.c.

266 {
267  Kit_Edge_t eNode0, eNode1, eNode;
268  if ( Type == 0 )
269  {
270  // derive the first AND
271  eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
272  // derive the second AND
273  eEdgeC.fCompl ^= 1;
274  eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
275  // derive the final OR
276  eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
277  }
278  else
279  {
280  // complement the arguments
281  eEdgeT.fCompl ^= 1;
282  eEdgeE.fCompl ^= 1;
283  // derive the first AND
284  eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
285  // derive the second AND
286  eEdgeC.fCompl ^= 1;
287  eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
288  // derive the final OR
289  eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
290  eNode.fCompl ^= 1;
291  }
292  return eNode;
293 }
Kit_Edge_t Kit_GraphAddNodeOr(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition: kitGraph.c:196
unsigned fCompl
Definition: kit.h:62
Kit_Edge_t Kit_GraphAddNodeAnd(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition: kitGraph.c:172
Kit_Edge_t Kit_GraphAddNodeOr ( Kit_Graph_t pGraph,
Kit_Edge_t  eEdge0,
Kit_Edge_t  eEdge1 
)

Function*************************************************************

Synopsis [Creates an OR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 196 of file kitGraph.c.

197 {
198  Kit_Node_t * pNode;
199  // get the new node
200  pNode = Kit_GraphAppendNode( pGraph );
201  // set the inputs and other info
202  pNode->eEdge0 = eEdge0;
203  pNode->eEdge1 = eEdge1;
204  pNode->fCompl0 = eEdge0.fCompl;
205  pNode->fCompl1 = eEdge1.fCompl;
206  // make adjustments for the OR gate
207  pNode->fNodeOr = 1;
208  pNode->eEdge0.fCompl = !pNode->eEdge0.fCompl;
209  pNode->eEdge1.fCompl = !pNode->eEdge1.fCompl;
210  return Kit_EdgeCreate( pGraph->nSize - 1, 1 );
211 }
unsigned fCompl1
Definition: kit.h:78
Kit_Edge_t eEdge0
Definition: kit.h:69
unsigned fNodeOr
Definition: kit.h:76
unsigned fCompl0
Definition: kit.h:77
Kit_Edge_t eEdge1
Definition: kit.h:70
int nSize
Definition: kit.h:90
static Kit_Edge_t Kit_EdgeCreate(int Node, int fCompl)
Definition: kit.h:194
unsigned fCompl
Definition: kit.h:62
Kit_Node_t * Kit_GraphAppendNode(Kit_Graph_t *pGraph)
Definition: kitGraph.c:148
Kit_Edge_t Kit_GraphAddNodeXor ( Kit_Graph_t pGraph,
Kit_Edge_t  eEdge0,
Kit_Edge_t  eEdge1,
int  Type 
)

Function*************************************************************

Synopsis [Creates an XOR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file kitGraph.c.

225 {
226  Kit_Edge_t eNode0, eNode1, eNode;
227  if ( Type == 0 )
228  {
229  // derive the first AND
230  eEdge0.fCompl ^= 1;
231  eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
232  eEdge0.fCompl ^= 1;
233  // derive the second AND
234  eEdge1.fCompl ^= 1;
235  eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
236  // derive the final OR
237  eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
238  }
239  else
240  {
241  // derive the first AND
242  eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
243  // derive the second AND
244  eEdge0.fCompl ^= 1;
245  eEdge1.fCompl ^= 1;
246  eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
247  // derive the final OR
248  eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
249  eNode.fCompl ^= 1;
250  }
251  return eNode;
252 }
Kit_Edge_t Kit_GraphAddNodeOr(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition: kitGraph.c:196
unsigned fCompl
Definition: kit.h:62
Kit_Edge_t Kit_GraphAddNodeAnd(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition: kitGraph.c:172
Kit_Node_t* Kit_GraphAppendNode ( Kit_Graph_t pGraph)

Function*************************************************************

Synopsis [Appends a new node to the graph.]

Description [This procedure is meant for internal use.]

SideEffects []

SeeAlso []

Definition at line 148 of file kitGraph.c.

149 {
150  Kit_Node_t * pNode;
151  if ( pGraph->nSize == pGraph->nCap )
152  {
153  pGraph->pNodes = ABC_REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
154  pGraph->nCap = 2 * pGraph->nCap;
155  }
156  pNode = pGraph->pNodes + pGraph->nSize++;
157  memset( pNode, 0, sizeof(Kit_Node_t) );
158  return pNode;
159 }
char * memset()
int nCap
Definition: kit.h:91
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int nSize
Definition: kit.h:90
Kit_Node_t * pNodes
Definition: kit.h:92
static void Kit_GraphComplement ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 207 of file kit.h.

207 { pGraph->eRoot.fCompl ^= 1; }
Kit_Edge_t eRoot
Definition: kit.h:93
unsigned fCompl
Definition: kit.h:62
Kit_Graph_t* Kit_GraphCreate ( int  nLeaves)

DECLARATIONS ///.

CFile****************************************************************

FileName [kitGraph.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Decomposition graph representation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitGraph.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Creates a graph with the given number of leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file kitGraph.c.

46 {
47  Kit_Graph_t * pGraph;
48  pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
49  memset( pGraph, 0, sizeof(Kit_Graph_t) );
50  pGraph->nLeaves = nLeaves;
51  pGraph->nSize = nLeaves;
52  pGraph->nCap = 2 * nLeaves + 50;
53  pGraph->pNodes = ABC_ALLOC( Kit_Node_t, pGraph->nCap );
54  memset( pGraph->pNodes, 0, sizeof(Kit_Node_t) * pGraph->nSize );
55  return pGraph;
56 }
char * memset()
int nCap
Definition: kit.h:91
int nSize
Definition: kit.h:90
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Kit_Node_t * pNodes
Definition: kit.h:92
int nLeaves
Definition: kit.h:89
Kit_Graph_t* Kit_GraphCreateConst0 ( )

Function*************************************************************

Synopsis [Creates constant 0 graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file kitGraph.c.

70 {
71  Kit_Graph_t * pGraph;
72  pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
73  memset( pGraph, 0, sizeof(Kit_Graph_t) );
74  pGraph->fConst = 1;
75  pGraph->eRoot.fCompl = 1;
76  return pGraph;
77 }
char * memset()
Kit_Edge_t eRoot
Definition: kit.h:93
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned fCompl
Definition: kit.h:62
int fConst
Definition: kit.h:88
Kit_Graph_t* Kit_GraphCreateConst1 ( )

Function*************************************************************

Synopsis [Creates constant 1 graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file kitGraph.c.

91 {
92  Kit_Graph_t * pGraph;
93  pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
94  memset( pGraph, 0, sizeof(Kit_Graph_t) );
95  pGraph->fConst = 1;
96  return pGraph;
97 }
char * memset()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int fConst
Definition: kit.h:88
Kit_Graph_t* Kit_GraphCreateLeaf ( int  iLeaf,
int  nLeaves,
int  fCompl 
)

Function*************************************************************

Synopsis [Creates the literal graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file kitGraph.c.

111 {
112  Kit_Graph_t * pGraph;
113  assert( 0 <= iLeaf && iLeaf < nLeaves );
114  pGraph = Kit_GraphCreate( nLeaves );
115  pGraph->eRoot.Node = iLeaf;
116  pGraph->eRoot.fCompl = fCompl;
117  return pGraph;
118 }
Kit_Edge_t eRoot
Definition: kit.h:93
unsigned fCompl
Definition: kit.h:62
unsigned Node
Definition: kit.h:63
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START Kit_Graph_t * Kit_GraphCreate(int nLeaves)
DECLARATIONS ///.
Definition: kitGraph.c:45
void Kit_GraphFree ( Kit_Graph_t pGraph)

Function*************************************************************

Synopsis [Creates a graph with the given number of leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file kitGraph.c.

132 {
133  ABC_FREE( pGraph->pNodes );
134  ABC_FREE( pGraph );
135 }
Kit_Node_t * pNodes
Definition: kit.h:92
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Kit_GraphIsComplement ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 205 of file kit.h.

205 { return pGraph->eRoot.fCompl; }
Kit_Edge_t eRoot
Definition: kit.h:93
unsigned fCompl
Definition: kit.h:62
static int Kit_GraphIsConst ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 202 of file kit.h.

202 { return pGraph->fConst; }
int fConst
Definition: kit.h:88
static int Kit_GraphIsConst0 ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 203 of file kit.h.

203 { return pGraph->fConst && pGraph->eRoot.fCompl; }
Kit_Edge_t eRoot
Definition: kit.h:93
unsigned fCompl
Definition: kit.h:62
int fConst
Definition: kit.h:88
static int Kit_GraphIsConst1 ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 204 of file kit.h.

204 { return pGraph->fConst && !pGraph->eRoot.fCompl; }
Kit_Edge_t eRoot
Definition: kit.h:93
unsigned fCompl
Definition: kit.h:62
int fConst
Definition: kit.h:88
static int Kit_GraphIsVar ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 206 of file kit.h.

206 { return pGraph->eRoot.Node < (unsigned)pGraph->nLeaves; }
Kit_Edge_t eRoot
Definition: kit.h:93
int nLeaves
Definition: kit.h:89
unsigned Node
Definition: kit.h:63
int Kit_GraphLeafDepth_rec ( Kit_Graph_t pGraph,
Kit_Node_t pNode,
Kit_Node_t pLeaf 
)

Function*************************************************************

Synopsis [Derives the maximum depth from the leaf to the root.]

Description []

SideEffects []

SeeAlso []

Definition at line 383 of file kitGraph.c.

384 {
385  int Depth0, Depth1, Depth;
386  if ( pNode == pLeaf )
387  return 0;
388  if ( Kit_GraphNodeIsVar(pGraph, pNode) )
389  return -100;
390  Depth0 = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeFanin0(pGraph, pNode), pLeaf );
391  Depth1 = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeFanin1(pGraph, pNode), pLeaf );
392  Depth = KIT_MAX( Depth0, Depth1 );
393  Depth = (Depth == -100) ? -100 : Depth + 1;
394  return Depth;
395 }
#define KIT_MAX(a, b)
Definition: kit.h:172
int Kit_GraphLeafDepth_rec(Kit_Graph_t *pGraph, Kit_Node_t *pNode, Kit_Node_t *pLeaf)
Definition: kitGraph.c:383
static Kit_Node_t * Kit_GraphNodeFanin0(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:217
static int Kit_GraphNodeIsVar(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:214
static Kit_Node_t * Kit_GraphNodeFanin1(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:218
static int Depth
Definition: dsdProc.c:56
static int Kit_GraphLeaveNum ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 209 of file kit.h.

209 { return pGraph->nLeaves; }
int nLeaves
Definition: kit.h:89
static Kit_Node_t* Kit_GraphNode ( Kit_Graph_t pGraph,
int  i 
)
inlinestatic

Definition at line 211 of file kit.h.

211 { return pGraph->pNodes + i; }
Kit_Node_t * pNodes
Definition: kit.h:92
static Kit_Node_t* Kit_GraphNodeFanin0 ( Kit_Graph_t pGraph,
Kit_Node_t pNode 
)
inlinestatic

Definition at line 217 of file kit.h.

217 { return Kit_GraphNodeIsVar(pGraph, pNode)? NULL : Kit_GraphNode(pGraph, pNode->eEdge0.Node); }
Kit_Edge_t eEdge0
Definition: kit.h:69
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
unsigned Node
Definition: kit.h:63
static int Kit_GraphNodeIsVar(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:214
static Kit_Node_t* Kit_GraphNodeFanin1 ( Kit_Graph_t pGraph,
Kit_Node_t pNode 
)
inlinestatic

Definition at line 218 of file kit.h.

218 { return Kit_GraphNodeIsVar(pGraph, pNode)? NULL : Kit_GraphNode(pGraph, pNode->eEdge1.Node); }
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
Kit_Edge_t eEdge1
Definition: kit.h:70
unsigned Node
Definition: kit.h:63
static int Kit_GraphNodeIsVar(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:214
static int Kit_GraphNodeInt ( Kit_Graph_t pGraph,
Kit_Node_t pNode 
)
inlinestatic

Definition at line 213 of file kit.h.

213 { return pNode - pGraph->pNodes; }
Kit_Node_t * pNodes
Definition: kit.h:92
static int Kit_GraphNodeIsVar ( Kit_Graph_t pGraph,
Kit_Node_t pNode 
)
inlinestatic

Definition at line 214 of file kit.h.

214 { return Kit_GraphNodeInt(pGraph,pNode) < pGraph->nLeaves; }
int nLeaves
Definition: kit.h:89
static int Kit_GraphNodeInt(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:213
static Kit_Node_t* Kit_GraphNodeLast ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 212 of file kit.h.

212 { return pGraph->pNodes + pGraph->nSize - 1; }
int nSize
Definition: kit.h:90
Kit_Node_t * pNodes
Definition: kit.h:92
static int Kit_GraphNodeNum ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 210 of file kit.h.

210 { return pGraph->nSize - pGraph->nLeaves; }
int nSize
Definition: kit.h:90
int nLeaves
Definition: kit.h:89
static int Kit_GraphRootLevel ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 219 of file kit.h.

219 { return Kit_GraphNode(pGraph, pGraph->eRoot.Node)->Level; }
Kit_Edge_t eRoot
Definition: kit.h:93
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
unsigned Node
Definition: kit.h:63
unsigned Level
Definition: kit.h:74
static void Kit_GraphSetRoot ( Kit_Graph_t pGraph,
Kit_Edge_t  eRoot 
)
inlinestatic

Definition at line 208 of file kit.h.

208 { pGraph->eRoot = eRoot; }
Kit_Edge_t eRoot
Definition: kit.h:93
DdNode* Kit_GraphToBdd ( DdManager dd,
Kit_Graph_t pGraph 
)

Function*************************************************************

Synopsis [Converts graph to BDD.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file kitBdd.c.

92 {
93  DdNode * bFunc, * bFunc0, * bFunc1;
94  Kit_Node_t * pNode = NULL; // Suppress "might be used uninitialized"
95  int i;
96 
97  // sanity checks
98  assert( Kit_GraphLeaveNum(pGraph) >= 0 );
99  assert( Kit_GraphLeaveNum(pGraph) <= pGraph->nSize );
100 
101  // check for constant function
102  if ( Kit_GraphIsConst(pGraph) )
103  return Cudd_NotCond( b1, Kit_GraphIsComplement(pGraph) );
104  // check for a literal
105  if ( Kit_GraphIsVar(pGraph) )
106  return Cudd_NotCond( Cudd_bddIthVar(dd, Kit_GraphVarInt(pGraph)), Kit_GraphIsComplement(pGraph) );
107 
108  // assign the elementary variables
109  Kit_GraphForEachLeaf( pGraph, pNode, i )
110  pNode->pFunc = Cudd_bddIthVar( dd, i );
111 
112  // compute the function for each internal node
113  Kit_GraphForEachNode( pGraph, pNode, i )
114  {
115  bFunc0 = Cudd_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
116  bFunc1 = Cudd_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
117  pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc );
118  }
119 
120  // deref the intermediate results
121  bFunc = (DdNode *)pNode->pFunc; Cudd_Ref( bFunc );
122  Kit_GraphForEachNode( pGraph, pNode, i )
123  Cudd_RecursiveDeref( dd, (DdNode *)pNode->pFunc );
124  Cudd_Deref( bFunc );
125 
126  // complement the result if necessary
127  return Cudd_NotCond( bFunc, Kit_GraphIsComplement(pGraph) );
128 }
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
#define b1
Definition: extraBdd.h:76
static int Kit_GraphIsComplement(Kit_Graph_t *pGraph)
Definition: kit.h:205
static int Kit_GraphLeaveNum(Kit_Graph_t *pGraph)
Definition: kit.h:209
int nSize
Definition: kit.h:90
static int Kit_GraphIsVar(Kit_Graph_t *pGraph)
Definition: kit.h:206
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)
Definition: kit.h:502
void * pFunc
Definition: kit.h:73
static int Kit_GraphIsConst(Kit_Graph_t *pGraph)
Definition: kit.h:202
#define Kit_GraphForEachNode(pGraph, pAnd, i)
Definition: kit.h:504
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define assert(ex)
Definition: util_old.h:213
static int Kit_GraphVarInt(Kit_Graph_t *pGraph)
Definition: kit.h:216
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
unsigned Kit_GraphToTruth ( Kit_Graph_t pGraph)

Function*************************************************************

Synopsis [Derives the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 306 of file kitGraph.c.

307 {
308  unsigned uTruths[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
309  unsigned uTruth = 0, uTruth0, uTruth1;
310  Kit_Node_t * pNode;
311  int i;
312 
313  // sanity checks
314  assert( Kit_GraphLeaveNum(pGraph) >= 0 );
315  assert( Kit_GraphLeaveNum(pGraph) <= pGraph->nSize );
316  assert( Kit_GraphLeaveNum(pGraph) <= 5 );
317 
318  // check for constant function
319  if ( Kit_GraphIsConst(pGraph) )
320  return Kit_GraphIsComplement(pGraph)? 0 : ~((unsigned)0);
321  // check for a literal
322  if ( Kit_GraphIsVar(pGraph) )
323  return Kit_GraphIsComplement(pGraph)? ~uTruths[Kit_GraphVarInt(pGraph)] : uTruths[Kit_GraphVarInt(pGraph)];
324 
325  // assign the elementary variables
326  Kit_GraphForEachLeaf( pGraph, pNode, i )
327  pNode->pFunc = (void *)(long)uTruths[i];
328 
329  // compute the function for each internal node
330  Kit_GraphForEachNode( pGraph, pNode, i )
331  {
332  uTruth0 = (unsigned)(long)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
333  uTruth1 = (unsigned)(long)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
334  uTruth0 = pNode->eEdge0.fCompl? ~uTruth0 : uTruth0;
335  uTruth1 = pNode->eEdge1.fCompl? ~uTruth1 : uTruth1;
336  uTruth = uTruth0 & uTruth1;
337  pNode->pFunc = (void *)(long)uTruth;
338  }
339 
340  // complement the result if necessary
341  return Kit_GraphIsComplement(pGraph)? ~uTruth : uTruth;
342 }
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
static int Kit_GraphIsComplement(Kit_Graph_t *pGraph)
Definition: kit.h:205
static int Kit_GraphLeaveNum(Kit_Graph_t *pGraph)
Definition: kit.h:209
int nSize
Definition: kit.h:90
static int Kit_GraphIsVar(Kit_Graph_t *pGraph)
Definition: kit.h:206
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)
Definition: kit.h:502
void * pFunc
Definition: kit.h:73
static int Kit_GraphIsConst(Kit_Graph_t *pGraph)
Definition: kit.h:202
#define Kit_GraphForEachNode(pGraph, pAnd, i)
Definition: kit.h:504
#define assert(ex)
Definition: util_old.h:213
static int Kit_GraphVarInt(Kit_Graph_t *pGraph)
Definition: kit.h:216
static Kit_Node_t* Kit_GraphVar ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 215 of file kit.h.

215 { assert( Kit_GraphIsVar( pGraph ) ); return Kit_GraphNode( pGraph, pGraph->eRoot.Node ); }
Kit_Edge_t eRoot
Definition: kit.h:93
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
static int Kit_GraphIsVar(Kit_Graph_t *pGraph)
Definition: kit.h:206
unsigned Node
Definition: kit.h:63
#define assert(ex)
Definition: util_old.h:213
static int Kit_GraphVarInt ( Kit_Graph_t pGraph)
inlinestatic

Definition at line 216 of file kit.h.

216 { assert( Kit_GraphIsVar( pGraph ) ); return Kit_GraphNodeInt( pGraph, Kit_GraphVar(pGraph) ); }
static int Kit_GraphIsVar(Kit_Graph_t *pGraph)
Definition: kit.h:206
static int Kit_GraphNodeInt(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:213
static Kit_Node_t * Kit_GraphVar(Kit_Graph_t *pGraph)
Definition: kit.h:215
#define assert(ex)
Definition: util_old.h:213
static Kit_Edge_t Kit_IntToEdge ( unsigned  Edge)
inlinestatic

Definition at line 196 of file kit.h.

196 { return Kit_EdgeCreate( Edge >> 1, Edge & 1 ); }
static Kit_Edge_t Kit_EdgeCreate(int Node, int fCompl)
Definition: kit.h:194
static Kit_Edge_t Kit_IntToEdge_ ( unsigned  m)
inlinestatic

Definition at line 200 of file kit.h.

200 { union { Kit_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
void Kit_PlaComplement ( char *  pSop)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file kitPla.c.

182 {
183  char * pCur;
184  for ( pCur = pSop; *pCur; pCur++ )
185  if ( *pCur == '\n' )
186  {
187  if ( *(pCur - 1) == '0' )
188  *(pCur - 1) = '1';
189  else if ( *(pCur - 1) == '1' )
190  *(pCur - 1) = '0';
191  else if ( *(pCur - 1) == 'x' )
192  *(pCur - 1) = 'n';
193  else if ( *(pCur - 1) == 'n' )
194  *(pCur - 1) = 'x';
195  else
196  assert( 0 );
197  }
198 }
#define assert(ex)
Definition: util_old.h:213
char* Kit_PlaCreateFromIsop ( void *  p,
int  nVars,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Creates the cover from the ISOP computed from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 243 of file kitPla.c.

244 {
245  Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
246  char * pSop, * pCube;
247  int i, k, Entry, Literal;
248  assert( Vec_IntSize(vCover) > 0 );
249  if ( Vec_IntSize(vCover) == 0 )
250  return NULL;
251  // start the cover
252  pSop = Kit_PlaStart( pMan, Vec_IntSize(vCover), nVars );
253  // create cubes
254  Vec_IntForEachEntry( vCover, Entry, i )
255  {
256  pCube = pSop + i * (nVars + 3);
257  for ( k = 0; k < nVars; k++ )
258  {
259  Literal = 3 & (Entry >> (k << 1));
260  if ( Literal == 1 )
261  pCube[k] = '0';
262  else if ( Literal == 2 )
263  pCube[k] = '1';
264  else if ( Literal != 0 )
265  assert( 0 );
266  }
267  }
268  return pSop;
269 }
char * Kit_PlaStart(void *p, int nCubes, int nVars)
Definition: kitPla.c:211
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
char* Kit_PlaFromTruth ( void *  p,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Transforms truth table into the SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 337 of file kitPla.c.

338 {
339  Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
340  char * pSop;
341  int RetValue;
342  if ( Kit_TruthIsConst0(pTruth, nVars) )
343  return Kit_PlaStoreSop( pMan, " 0\n" );
344  if ( Kit_TruthIsConst1(pTruth, nVars) )
345  return Kit_PlaStoreSop( pMan, " 1\n" );
346  RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 0 ); // 1 );
347  assert( RetValue == 0 || RetValue == 1 );
348  pSop = Kit_PlaCreateFromIsop( pMan, nVars, vCover );
349  if ( RetValue )
350  Kit_PlaComplement( pSop );
351  return pSop;
352 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * Kit_PlaStoreSop(void *p, char *pSop)
Definition: kitPla.c:317
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
char * Kit_PlaCreateFromIsop(void *p, int nVars, Vec_Int_t *vCover)
Definition: kitPla.c:243
#define assert(ex)
Definition: util_old.h:213
void Kit_PlaComplement(char *pSop)
Definition: kitPla.c:181
char* Kit_PlaFromTruthNew ( unsigned *  pTruth,
int  nVars,
Vec_Int_t vCover,
Vec_Str_t vStr 
)

Function*************************************************************

Synopsis [Creates the SOP from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 406 of file kitPla.c.

407 {
408  char * pResult;
409  // transform truth table into the SOP
410  int RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 1 );
411  assert( RetValue == 0 || RetValue == 1 );
412  // check the case of constant cover
413  if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
414  {
415  assert( RetValue == 0 );
416  Vec_StrClear( vStr );
417  Vec_StrAppend( vStr, (Vec_IntSize(vCover) == 0) ? " 0\n" : " 1\n" );
418  Vec_StrPush( vStr, '\0' );
419  return Vec_StrArray( vStr );
420  }
421  pResult = Kit_PlaFromIsop( vStr, nVars, vCover );
422  if ( RetValue )
423  Kit_PlaComplement( pResult );
424  if ( nVars < 6 )
425  assert( pTruth[0] == (unsigned)Kit_PlaToTruth6(pResult, nVars) );
426  else if ( nVars == 6 )
427  assert( *((ABC_UINT64_T*)pTruth) == Kit_PlaToTruth6(pResult, nVars) );
428  return pResult;
429 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
char * Kit_PlaFromIsop(Vec_Str_t *vStr, int nVars, Vec_Int_t *vCover)
Definition: kitPla.c:366
static void Vec_StrAppend(Vec_Str_t *p, const char *pString)
Definition: vecStr.h:645
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
ABC_UINT64_T Kit_PlaToTruth6(char *pSop, int nVars)
Definition: kitPla.c:442
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
void Kit_PlaComplement(char *pSop)
Definition: kitPla.c:181
int Kit_PlaGetCubeNum ( char *  pSop)

Function*************************************************************

Synopsis [Reads the number of cubes in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 138 of file kitPla.c.

139 {
140  char * pCur;
141  int nCubes = 0;
142  if ( pSop == NULL )
143  return 0;
144  for ( pCur = pSop; *pCur; pCur++ )
145  nCubes += (*pCur == '\n');
146  return nCubes;
147 }
int Kit_PlaGetVarNum ( char *  pSop)

Function*************************************************************

Synopsis [Reads the number of variables in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file kitPla.c.

119 {
120  char * pCur;
121  for ( pCur = pSop; *pCur != '\n'; pCur++ )
122  if ( *pCur == 0 )
123  return -1;
124  return pCur - pSop - 2;
125 }
int Kit_PlaIsBuf ( char *  pSop)

Function*************************************************************

Synopsis [Checks if the cover is a buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file kitPla.c.

79 {
80  if ( pSop[4] != 0 )
81  return 0;
82  if ( (pSop[0] == '1' && pSop[2] == '1') || (pSop[0] == '0' && pSop[2] == '0') )
83  return 1;
84  return 0;
85 }
int Kit_PlaIsComplement ( char *  pSop)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file kitPla.c.

161 {
162  char * pCur;
163  for ( pCur = pSop; *pCur; pCur++ )
164  if ( *pCur == '\n' )
165  return (int)(*(pCur - 1) == '0' || *(pCur - 1) == 'n');
166  assert( 0 );
167  return 0;
168 }
#define assert(ex)
Definition: util_old.h:213
int Kit_PlaIsConst0 ( char *  pSop)

DECLARATIONS ///.

CFile****************************************************************

FileName [kitPla.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Manipulating SOP in the form of a C-string.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitPla.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Checks if the cover is constant 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file kitPla.c.

47 {
48  return pSop[0] == ' ' && pSop[1] == '0';
49 }
int Kit_PlaIsConst1 ( char *  pSop)

Function*************************************************************

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file kitPla.c.

63 {
64  return pSop[0] == ' ' && pSop[1] == '1';
65 }
int Kit_PlaIsInv ( char *  pSop)

Function*************************************************************

Synopsis [Checks if the cover is an inverter.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file kitPla.c.

99 {
100  if ( pSop[4] != 0 )
101  return 0;
102  if ( (pSop[0] == '0' && pSop[2] == '1') || (pSop[0] == '1' && pSop[2] == '0') )
103  return 1;
104  return 0;
105 }
char* Kit_PlaStart ( void *  p,
int  nCubes,
int  nVars 
)

Function*************************************************************

Synopsis [Creates the constant 1 cover with the given number of variables and cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 211 of file kitPla.c.

212 {
213  Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
214  char * pSopCover, * pCube;
215  int i, Length;
216 
217  Length = nCubes * (nVars + 3);
218  pSopCover = Aig_MmFlexEntryFetch( pMan, Length + 1 );
219  memset( pSopCover, '-', Length );
220  pSopCover[Length] = 0;
221 
222  for ( i = 0; i < nCubes; i++ )
223  {
224  pCube = pSopCover + i * (nVars + 3);
225  pCube[nVars + 0] = ' ';
226  pCube[nVars + 1] = '1';
227  pCube[nVars + 2] = '\n';
228  }
229  return pSopCover;
230 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char* Kit_PlaStoreSop ( void *  p,
char *  pSop 
)

Function*************************************************************

Synopsis [Allocates memory and copies the SOP into it.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file kitPla.c.

318 {
319  Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
320  char * pStore;
321  pStore = Aig_MmFlexEntryFetch( pMan, strlen(pSop) + 1 );
322  strcpy( pStore, pSop );
323  return pStore;
324 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * strcpy()
int strlen()
void Kit_PlaToIsop ( char *  pSop,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Creates the cover from the ISOP computed from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file kitPla.c.

283 {
284  char * pCube;
285  int k, nVars, Entry;
286  nVars = Kit_PlaGetVarNum( pSop );
287  assert( nVars > 0 );
288  // create cubes
289  Vec_IntClear( vCover );
290  for ( pCube = pSop; *pCube; pCube += nVars + 3 )
291  {
292  Entry = 0;
293  for ( k = nVars - 1; k >= 0; k-- )
294  if ( pCube[k] == '0' )
295  Entry = (Entry << 2) | 1;
296  else if ( pCube[k] == '1' )
297  Entry = (Entry << 2) | 2;
298  else if ( pCube[k] == '-' )
299  Entry = (Entry << 2);
300  else
301  assert( 0 );
302  Vec_IntPush( vCover, Entry );
303  }
304 }
int Kit_PlaGetVarNum(char *pSop)
Definition: kitPla.c:118
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Kit_PlaToTruth ( char *  pSop,
int  nVars,
Vec_Ptr_t vVars,
unsigned *  pTemp,
unsigned *  pTruth 
)

Fnction*************************************************************

Synopsis [Converting SOP into a truth table.]

Description [The SOP is represented as a C-string, as documented in file "bblif.h". The truth table is returned as a bit-string composed of 2^nVars bits. For functions of less than 6 variables, the full machine word is returned. (The truth table looks as if the function had 5 variables.) The use of this procedure should be limited to Boolean functions with no more than 16 inputs.]

SideEffects []

SeeAlso []

Definition at line 496 of file kitPla.c.

497 {
498  int v, c, nCubes, fCompl = 0;
499  assert( pSop != NULL );
500  assert( nVars >= 0 );
501  if ( strlen(pSop) % (nVars + 3) != 0 )
502  {
503  printf( "Kit_PlaToTruth(): SOP is represented incorrectly.\n" );
504  return;
505  }
506  // iterate through the cubes
507  Kit_TruthClear( pTruth, nVars );
508  nCubes = strlen(pSop) / (nVars + 3);
509  for ( c = 0; c < nCubes; c++ )
510  {
511  fCompl = (pSop[nVars+1] == '0');
512  Kit_TruthFill( pTemp, nVars );
513  // iterate through the literals of the cube
514  for ( v = 0; v < nVars; v++ )
515  if ( pSop[v] == '1' )
516  Kit_TruthAnd( pTemp, pTemp, (unsigned *)Vec_PtrEntry(vVars, v), nVars );
517  else if ( pSop[v] == '0' )
518  Kit_TruthSharp( pTemp, pTemp, (unsigned *)Vec_PtrEntry(vVars, v), nVars );
519  // add cube to storage
520  Kit_TruthOr( pTruth, pTruth, pTemp, nVars );
521  // go to the next cube
522  pSop += (nVars + 3);
523  }
524  if ( fCompl )
525  Kit_TruthNot( pTruth, pTruth, nVars );
526 }
static void Kit_TruthFill(unsigned *pOut, int nVars)
Definition: kit.h:367
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static void Kit_TruthSharp(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:397
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
int strlen()
static void Kit_TruthClear(unsigned *pOut, int nVars)
Definition: kit.h:361
static void Kit_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:385
ABC_UINT64_T Kit_PlaToTruth6 ( char *  pSop,
int  nVars 
)

Function*************************************************************

Synopsis [Converts SOP into a truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file kitPla.c.

443 {
444  static ABC_UINT64_T Truth[8] = {
445  ABC_CONST(0xAAAAAAAAAAAAAAAA),
446  ABC_CONST(0xCCCCCCCCCCCCCCCC),
447  ABC_CONST(0xF0F0F0F0F0F0F0F0),
448  ABC_CONST(0xFF00FF00FF00FF00),
449  ABC_CONST(0xFFFF0000FFFF0000),
450  ABC_CONST(0xFFFFFFFF00000000),
451  ABC_CONST(0x0000000000000000),
452  ABC_CONST(0xFFFFFFFFFFFFFFFF)
453  };
454  ABC_UINT64_T valueAnd, valueOr = Truth[6];
455  int v, lit = 0;
456  assert( nVars < 7 );
457  do {
458  valueAnd = Truth[7];
459  for ( v = 0; v < nVars; v++, lit++ )
460  {
461  if ( pSop[lit] == '1' )
462  valueAnd &= Truth[v];
463  else if ( pSop[lit] == '0' )
464  valueAnd &= ~Truth[v];
465  else if ( pSop[lit] != '-' )
466  assert( 0 );
467  }
468  valueOr |= valueAnd;
469  assert( pSop[lit] == ' ' );
470  lit++;
471  lit++;
472  assert( pSop[lit] == '\n' );
473  lit++;
474  } while ( pSop[lit] );
475  if ( Kit_PlaIsComplement(pSop) )
476  valueOr = ~valueOr;
477  return valueOr;
478 }
int Kit_PlaIsComplement(char *pSop)
Definition: kitPla.c:160
int lit
Definition: satVec.h:130
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define assert(ex)
Definition: util_old.h:213
int Kit_SopAnyLiteral ( Kit_Sop_t cSop,
int  nLits 
)

Function*************************************************************

Synopsis [Find any literal that occurs more than once.]

Description []

SideEffects []

SeeAlso []

Definition at line 370 of file kitSop.c.

371 {
372  unsigned uCube;
373  int i, k, nLitsCur;
374  // go through each literal
375  for ( i = 0; i < nLits; i++ )
376  {
377  // go through all the cubes
378  nLitsCur = 0;
379  Kit_SopForEachCube( cSop, uCube, k )
380  if ( Kit_CubeHasLit(uCube, i) )
381  nLitsCur++;
382  if ( nLitsCur > 1 )
383  return i;
384  }
385  return -1;
386 }
static int Kit_CubeHasLit(unsigned uCube, int i)
Definition: kit.h:175
if(last==0)
Definition: sparse_int.h:34
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
void Kit_SopBestLiteralCover ( Kit_Sop_t cResult,
Kit_Sop_t cSop,
unsigned  uCube,
int  nLits,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Create the one-literal cover with the best literal from cSop.]

Description []

SideEffects []

SeeAlso []

Definition at line 560 of file kitSop.c.

561 {
562  int iLitBest;
563  // get the best literal
564  iLitBest = Kit_SopBestLiteral( cSop, nLits, uCube );
565  // start the cover
566  cResult->nCubes = 0;
567  cResult->pCubes = Vec_IntFetch( vMemory, 1 );
568  // set the cube
569  Kit_SopPushCube( cResult, Kit_CubeSetLit(0, iLitBest) );
570 }
int Kit_SopBestLiteral(Kit_Sop_t *cSop, int nLits, unsigned uMask)
Definition: kitSop.c:454
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
static unsigned Kit_CubeSetLit(unsigned uCube, int i)
Definition: kit.h:176
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
void Kit_SopCommonCubeCover ( Kit_Sop_t cResult,
Kit_Sop_t cSop,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Creates SOP composes of the common cube of the given SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 350 of file kitSop.c.

351 {
352  assert( Kit_SopCubeNum(cSop) > 0 );
353  cResult->nCubes = 0;
354  cResult->pCubes = Vec_IntFetch( vMemory, 1 );
355  Kit_SopPushCube( cResult, Kit_SopCommonCube(cSop) );
356 }
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
static unsigned Kit_SopCommonCube(Kit_Sop_t *cSop)
Definition: kitSop.c:290
#define assert(ex)
Definition: util_old.h:213
static int Kit_SopCubeNum(Kit_Sop_t *cSop)
Definition: kit.h:188
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
void Kit_SopCreate ( Kit_Sop_t cResult,
Vec_Int_t vInput,
int  nVars,
Vec_Int_t vMemory 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [kitSop.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Procedures involving SOPs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitSop.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Creates SOP from the cube array.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file kitSop.c.

46 {
47  unsigned uCube;
48  int i;
49  // start the cover
50  cResult->nCubes = 0;
51  cResult->pCubes = Vec_IntFetch( vMemory, Vec_IntSize(vInput) );
52  // add the cubes
53  Vec_IntForEachEntry( vInput, uCube, i )
54  Kit_SopPushCube( cResult, uCube );
55 }
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
void Kit_SopCreateInverse ( Kit_Sop_t cResult,
Vec_Int_t vInput,
int  nLits,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Creates SOP from the cube array.]

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file kitSop.c.

69 {
70  unsigned uCube, uMask = 0;
71  int i, nCubes = Vec_IntSize(vInput);
72  // start the cover
73  cResult->nCubes = 0;
74  cResult->pCubes = Vec_IntFetch( vMemory, nCubes );
75  // add the cubes
76 // Vec_IntForEachEntry( vInput, uCube, i )
77  for ( i = 0; i < nCubes; i++ )
78  {
79  uCube = Vec_IntEntry( vInput, i );
80  uMask = ((uCube | (uCube >> 1)) & 0x55555555);
81  uMask |= (uMask << 1);
82  Kit_SopPushCube( cResult, uCube ^ uMask );
83  }
84 }
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
static unsigned Kit_SopCube ( Kit_Sop_t cSop,
int  i 
)
inlinestatic

Definition at line 189 of file kit.h.

189 { return cSop->pCubes[i]; }
static int Kit_SopCubeNum ( Kit_Sop_t cSop)
inlinestatic

Definition at line 188 of file kit.h.

188 { return cSop->nCubes; }
void Kit_SopDivideByCube ( Kit_Sop_t cSop,
Kit_Sop_t cDiv,
Kit_Sop_t vQuo,
Kit_Sop_t vRem,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Divides cover by one cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file kitSop.c.

146 {
147  unsigned uCube, uDiv;
148  int i;
149  // get the only cube
150  assert( Kit_SopCubeNum(cDiv) == 1 );
151  uDiv = Kit_SopCube(cDiv, 0);
152  // allocate covers
153  vQuo->nCubes = 0;
154  vQuo->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) );
155  vRem->nCubes = 0;
156  vRem->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) );
157  // sort the cubes
158  Kit_SopForEachCube( cSop, uCube, i )
159  {
160  if ( Kit_CubeContains( uCube, uDiv ) )
161  Kit_SopPushCube( vQuo, Kit_CubeSharp(uCube, uDiv) );
162  else
163  Kit_SopPushCube( vRem, uCube );
164  }
165 }
static unsigned Kit_SopCube(Kit_Sop_t *cSop, int i)
Definition: kit.h:189
static int Kit_CubeContains(unsigned uLarge, unsigned uSmall)
Definition: kit.h:180
static unsigned Kit_CubeSharp(unsigned uCube, unsigned uMask)
Definition: kit.h:181
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
#define assert(ex)
Definition: util_old.h:213
static int Kit_SopCubeNum(Kit_Sop_t *cSop)
Definition: kit.h:188
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
void Kit_SopDivideByLiteralQuo ( Kit_Sop_t cSop,
int  iLit 
)

Function*************************************************************

Synopsis [Derives the quotient of division by literal.]

Description [Reduces the cover to be equal to the result of division of the given cover by the literal.]

SideEffects []

SeeAlso []

Definition at line 121 of file kitSop.c.

122 {
123  unsigned uCube;
124  int i, k = 0;
125  Kit_SopForEachCube( cSop, uCube, i )
126  {
127  if ( Kit_CubeHasLit(uCube, iLit) )
128  Kit_SopWriteCube( cSop, Kit_CubeRemLit(uCube, iLit), k++ );
129  }
130  Kit_SopShrink( cSop, k );
131 }
static int Kit_CubeHasLit(unsigned uCube, int i)
Definition: kit.h:175
static unsigned Kit_CubeRemLit(unsigned uCube, int i)
Definition: kit.h:178
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
static void Kit_SopWriteCube(Kit_Sop_t *cSop, unsigned uCube, int i)
Definition: kit.h:192
static void Kit_SopShrink(Kit_Sop_t *cSop, int nCubesNew)
Definition: kit.h:190
void Kit_SopDivideInternal ( Kit_Sop_t cSop,
Kit_Sop_t cDiv,
Kit_Sop_t vQuo,
Kit_Sop_t vRem,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Divides cover by one cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file kitSop.c.

179 {
180  unsigned uCube, uDiv;
181  unsigned uCube2 = 0; // Suppress "might be used uninitialized"
182  unsigned uDiv2, uQuo;
183  int i, i2, k, k2, nCubesRem;
184  assert( Kit_SopCubeNum(cSop) >= Kit_SopCubeNum(cDiv) );
185  // consider special case
186  if ( Kit_SopCubeNum(cDiv) == 1 )
187  {
188  Kit_SopDivideByCube( cSop, cDiv, vQuo, vRem, vMemory );
189  return;
190  }
191  // allocate quotient
192  vQuo->nCubes = 0;
193  vQuo->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) / Kit_SopCubeNum(cDiv) );
194  // for each cube of the cover
195  // it either belongs to the quotient or to the remainder
196  Kit_SopForEachCube( cSop, uCube, i )
197  {
198  // skip taken cubes
199  if ( Kit_CubeIsMarked(uCube) )
200  continue;
201  // find a matching cube in the divisor
202  uDiv = ~0;
203  Kit_SopForEachCube( cDiv, uDiv, k )
204  if ( Kit_CubeContains( uCube, uDiv ) )
205  break;
206  // the cube is not found
207  if ( k == Kit_SopCubeNum(cDiv) )
208  continue;
209  // the quotient cube exists
210  uQuo = Kit_CubeSharp( uCube, uDiv );
211  // find corresponding cubes for other cubes of the divisor
212  uDiv2 = ~0;
213  Kit_SopForEachCube( cDiv, uDiv2, k2 )
214  {
215  if ( k2 == k )
216  continue;
217  // find a matching cube
218  Kit_SopForEachCube( cSop, uCube2, i2 )
219  {
220  // skip taken cubes
221  if ( Kit_CubeIsMarked(uCube2) )
222  continue;
223  // check if the cube can be used
224  if ( Kit_CubeContains( uCube2, uDiv2 ) && uQuo == Kit_CubeSharp( uCube2, uDiv2 ) )
225  break;
226  }
227  // the case when the cube is not found
228  if ( i2 == Kit_SopCubeNum(cSop) )
229  break;
230  }
231  // we did not find some cubes - continue looking at other cubes
232  if ( k2 != Kit_SopCubeNum(cDiv) )
233  continue;
234  // we found all cubes - add the quotient cube
235  Kit_SopPushCube( vQuo, uQuo );
236 
237  // mark the first cube
238  Kit_SopWriteCube( cSop, Kit_CubeMark(uCube), i );
239  // mark other cubes that have this quotient
240  Kit_SopForEachCube( cDiv, uDiv2, k2 )
241  {
242  if ( k2 == k )
243  continue;
244  // find a matching cube
245  Kit_SopForEachCube( cSop, uCube2, i2 )
246  {
247  // skip taken cubes
248  if ( Kit_CubeIsMarked(uCube2) )
249  continue;
250  // check if the cube can be used
251  if ( Kit_CubeContains( uCube2, uDiv2 ) && uQuo == Kit_CubeSharp( uCube2, uDiv2 ) )
252  break;
253  }
254  assert( i2 < Kit_SopCubeNum(cSop) );
255  // the cube is found, mark it
256  // (later we will add all unmarked cubes to the remainder)
257  Kit_SopWriteCube( cSop, Kit_CubeMark(uCube2), i2 );
258  }
259  }
260  // determine the number of cubes in the remainder
261  nCubesRem = Kit_SopCubeNum(cSop) - Kit_SopCubeNum(vQuo) * Kit_SopCubeNum(cDiv);
262  // allocate remainder
263  vRem->nCubes = 0;
264  vRem->pCubes = Vec_IntFetch( vMemory, nCubesRem );
265  // finally add the remaining unmarked cubes to the remainder
266  // and clean the marked cubes in the cover
267  Kit_SopForEachCube( cSop, uCube, i )
268  {
269  if ( !Kit_CubeIsMarked(uCube) )
270  {
271  Kit_SopPushCube( vRem, uCube );
272  continue;
273  }
274  Kit_SopWriteCube( cSop, Kit_CubeUnmark(uCube), i );
275  }
276  assert( nCubesRem == Kit_SopCubeNum(vRem) );
277 }
static int Kit_CubeContains(unsigned uLarge, unsigned uSmall)
Definition: kit.h:180
static unsigned Kit_CubeSharp(unsigned uCube, unsigned uMask)
Definition: kit.h:181
static int Kit_CubeIsMarked(unsigned uCube)
Definition: kit.h:184
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
if(last==0)
Definition: sparse_int.h:34
static unsigned Kit_CubeMark(unsigned uCube)
Definition: kit.h:185
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
static void Kit_SopWriteCube(Kit_Sop_t *cSop, unsigned uCube, int i)
Definition: kit.h:192
void Kit_SopDivideByCube(Kit_Sop_t *cSop, Kit_Sop_t *cDiv, Kit_Sop_t *vQuo, Kit_Sop_t *vRem, Vec_Int_t *vMemory)
Definition: kitSop.c:145
static unsigned Kit_CubeUnmark(unsigned uCube)
Definition: kit.h:186
#define assert(ex)
Definition: util_old.h:213
static int Kit_SopCubeNum(Kit_Sop_t *cSop)
Definition: kit.h:188
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
int Kit_SopDivisor ( Kit_Sop_t cResult,
Kit_Sop_t cSop,
int  nLits,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Computes the quick divisor of the cover.]

Description [Returns 0, if there is no divisor other than trivial.]

SideEffects []

SeeAlso []

Definition at line 534 of file kitSop.c.

535 {
536  if ( Kit_SopCubeNum(cSop) <= 1 )
537  return 0;
538  if ( Kit_SopAnyLiteral( cSop, nLits ) == -1 )
539  return 0;
540  // duplicate the cover
541  Kit_SopDup( cResult, cSop, vMemory );
542  // perform the kerneling
543  Kit_SopDivisorZeroKernel_rec( cResult, nLits );
544  assert( Kit_SopCubeNum(cResult) > 0 );
545  return 1;
546 }
void Kit_SopDup(Kit_Sop_t *cResult, Kit_Sop_t *cSop, Vec_Int_t *vMemory)
Definition: kitSop.c:97
#define assert(ex)
Definition: util_old.h:213
int Kit_SopAnyLiteral(Kit_Sop_t *cSop, int nLits)
Definition: kitSop.c:370
static int Kit_SopCubeNum(Kit_Sop_t *cSop)
Definition: kit.h:188
void Kit_SopDivisorZeroKernel_rec(Kit_Sop_t *cSop, int nLits)
Definition: kitSop.c:509
void Kit_SopDup ( Kit_Sop_t cResult,
Kit_Sop_t cSop,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Duplicates SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file kitSop.c.

98 {
99  unsigned uCube;
100  int i;
101  // start the cover
102  cResult->nCubes = 0;
103  cResult->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) );
104  // add the cubes
105  Kit_SopForEachCube( cSop, uCube, i )
106  Kit_SopPushCube( cResult, uCube );
107 }
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
static int Kit_SopCubeNum(Kit_Sop_t *cSop)
Definition: kit.h:188
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
Kit_Graph_t* Kit_SopFactor ( Vec_Int_t vCover,
int  fCompl,
int  nVars,
Vec_Int_t vMemory 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Factors the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file kitFactor.c.

56 {
57  Kit_Sop_t Sop, * cSop = &Sop;
58  Kit_Graph_t * pFForm;
59  Kit_Edge_t eRoot;
60 // int nCubes;
61 
62  // works for up to 15 variables because division procedure
63  // used the last bit for marking the cubes going to the remainder
64  assert( nVars < 16 );
65 
66  // check for trivial functions
67  if ( Vec_IntSize(vCover) == 0 )
68  return Kit_GraphCreateConst0();
69  if ( Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0 )
70  return Kit_GraphCreateConst1();
71 
72  // prepare memory manager
73 // Vec_IntClear( vMemory );
75 
76  // perform CST
77  Kit_SopCreateInverse( cSop, vCover, 2 * nVars, vMemory ); // CST
78 
79  // start the factored form
80  pFForm = Kit_GraphCreate( nVars );
81  // factor the cover
82  eRoot = Kit_SopFactor_rec( pFForm, cSop, 2 * nVars, vMemory );
83  // finalize the factored form
84  Kit_GraphSetRoot( pFForm, eRoot );
85  if ( fCompl )
86  Kit_GraphComplement( pFForm );
87 
88  // verify the factored form
89 // nCubes = Vec_IntSize(vCover);
90 // Vec_IntShrink( vCover, nCubes );
91 // if ( !Kit_SopFactorVerify( vCover, pFForm, nVars ) )
92 // printf( "Verification has failed.\n" );
93  return pFForm;
94 }
#define KIT_FACTOR_MEM_LIMIT
DECLARATIONS ///.
Definition: kitFactor.c:31
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Kit_Edge_t Kit_SopFactor_rec(Kit_Graph_t *pFForm, Kit_Sop_t *cSop, int nLits, Vec_Int_t *vMemory)
Definition: kitFactor.c:108
Kit_Graph_t * Kit_GraphCreate(int nLeaves)
DECLARATIONS ///.
Definition: kitGraph.c:45
Kit_Graph_t * Kit_GraphCreateConst1()
Definition: kitGraph.c:90
Kit_Graph_t * Kit_GraphCreateConst0()
Definition: kitGraph.c:69
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
Definition: kit.h:51
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Kit_GraphSetRoot(Kit_Graph_t *pGraph, Kit_Edge_t eRoot)
Definition: kit.h:208
void Kit_SopCreateInverse(Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
Definition: kitSop.c:68
#define assert(ex)
Definition: util_old.h:213
static void Kit_GraphComplement(Kit_Graph_t *pGraph)
Definition: kit.h:207
int Kit_SopIsCubeFree ( Kit_Sop_t cSop)

Function*************************************************************

Synopsis [Checks if the cover is cube-free.]

Description []

SideEffects []

SeeAlso []

Definition at line 334 of file kitSop.c.

335 {
336  return Kit_SopCommonCube( cSop ) == 0;
337 }
static unsigned Kit_SopCommonCube(Kit_Sop_t *cSop)
Definition: kitSop.c:290
void Kit_SopMakeCubeFree ( Kit_Sop_t cSop)

Function*************************************************************

Synopsis [Makes the cover cube-free.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file kitSop.c.

312 {
313  unsigned uMask, uCube;
314  int i;
315  uMask = Kit_SopCommonCube( cSop );
316  if ( uMask == 0 )
317  return;
318  // remove the common cube
319  Kit_SopForEachCube( cSop, uCube, i )
320  Kit_SopWriteCube( cSop, Kit_CubeSharp(uCube, uMask), i );
321 }
static unsigned Kit_CubeSharp(unsigned uCube, unsigned uMask)
Definition: kit.h:181
static unsigned Kit_SopCommonCube(Kit_Sop_t *cSop)
Definition: kitSop.c:290
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
static void Kit_SopWriteCube(Kit_Sop_t *cSop, unsigned uCube, int i)
Definition: kit.h:192
static void Kit_SopPushCube ( Kit_Sop_t cSop,
unsigned  uCube 
)
inlinestatic

Definition at line 191 of file kit.h.

191 { cSop->pCubes[cSop->nCubes++] = uCube; }
static void Kit_SopShrink ( Kit_Sop_t cSop,
int  nCubesNew 
)
inlinestatic

Definition at line 190 of file kit.h.

190 { cSop->nCubes = nCubesNew; }
DdNode* Kit_SopToBdd ( DdManager dd,
Kit_Sop_t cSop,
int  nVars 
)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

CFile****************************************************************

FileName [kitBdd.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Procedures involving BDDs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitBdd.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Derives the BDD for the given SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file kitBdd.c.

47 {
48  DdNode * bSum, * bCube, * bTemp, * bVar;
49  unsigned uCube;
50  int Value, i, v;
51  assert( nVars < 16 );
52  // start the cover
53  bSum = Cudd_ReadLogicZero(dd); Cudd_Ref( bSum );
54  // check the logic function of the node
55  Kit_SopForEachCube( cSop, uCube, i )
56  {
57  bCube = Cudd_ReadOne(dd); Cudd_Ref( bCube );
58  for ( v = 0; v < nVars; v++ )
59  {
60  Value = ((uCube >> 2*v) & 3);
61  if ( Value == 1 )
62  bVar = Cudd_Not( Cudd_bddIthVar( dd, v ) );
63  else if ( Value == 2 )
64  bVar = Cudd_bddIthVar( dd, v );
65  else
66  continue;
67  bCube = Cudd_bddAnd( dd, bTemp = bCube, bVar ); Cudd_Ref( bCube );
68  Cudd_RecursiveDeref( dd, bTemp );
69  }
70  bSum = Cudd_bddOr( dd, bTemp = bSum, bCube );
71  Cudd_Ref( bSum );
72  Cudd_RecursiveDeref( dd, bTemp );
73  Cudd_RecursiveDeref( dd, bCube );
74  }
75  // complement the result if necessary
76  Cudd_Deref( bSum );
77  return bSum;
78 }
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
DdNode * Cudd_bddOr(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:381
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition: kit.h:497
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define assert(ex)
Definition: util_old.h:213
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
static void Kit_SopWriteCube ( Kit_Sop_t cSop,
unsigned  uCube,
int  i 
)
inlinestatic

Definition at line 192 of file kit.h.

192 { cSop->pCubes[i] = uCube; }
static int Kit_SuppIsMinBase ( int  Supp)
inlinestatic

Definition at line 221 of file kit.h.

221 { return (Supp & (Supp+1)) == 0; }
static void Kit_TruthAnd ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 379 of file kit.h.

380 {
381  int w;
382  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
383  pOut[w] = pIn0[w] & pIn1[w];
384 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Kit_TruthAndPhase ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars,
int  fCompl0,
int  fCompl1 
)
inlinestatic

Definition at line 409 of file kit.h.

410 {
411  int w;
412  if ( fCompl0 && fCompl1 )
413  {
414  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
415  pOut[w] = ~(pIn0[w] | pIn1[w]);
416  }
417  else if ( fCompl0 && !fCompl1 )
418  {
419  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
420  pOut[w] = ~pIn0[w] & pIn1[w];
421  }
422  else if ( !fCompl0 && fCompl1 )
423  {
424  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
425  pOut[w] = pIn0[w] & ~pIn1[w];
426  }
427  else // if ( !fCompl0 && !fCompl1 )
428  {
429  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
430  pOut[w] = pIn0[w] & pIn1[w];
431  }
432 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int Kit_TruthBestCofVar ( unsigned *  pTruth,
int  nVars,
unsigned *  pCof0,
unsigned *  pCof1 
)

Function*************************************************************

Synopsis [Find the best cofactoring variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 1365 of file kitTruth.c.

1366 {
1367  int i, iBestVar, nSuppSizeCur0, nSuppSizeCur1, nSuppSizeCur, nSuppSizeMin;
1368  if ( Kit_TruthIsConst0(pTruth, nVars) || Kit_TruthIsConst1(pTruth, nVars) )
1369  return -1;
1370  // iterate through variables
1371  iBestVar = -1;
1372  nSuppSizeMin = KIT_INFINITY;
1373  for ( i = 0; i < nVars; i++ )
1374  {
1375  // cofactor the functiona and get support sizes
1376  Kit_TruthCofactor0New( pCof0, pTruth, nVars, i );
1377  Kit_TruthCofactor1New( pCof1, pTruth, nVars, i );
1378  nSuppSizeCur0 = Kit_TruthSupportSize( pCof0, nVars );
1379  nSuppSizeCur1 = Kit_TruthSupportSize( pCof1, nVars );
1380  nSuppSizeCur = nSuppSizeCur0 + nSuppSizeCur1;
1381  // compare this variable with other variables
1382  if ( nSuppSizeMin > nSuppSizeCur )
1383  {
1384  nSuppSizeMin = nSuppSizeCur;
1385  iBestVar = i;
1386  }
1387  }
1388  assert( iBestVar != -1 );
1389  // cofactor w.r.t. this variable
1390  Kit_TruthCofactor0New( pCof0, pTruth, nVars, iBestVar );
1391  Kit_TruthCofactor1New( pCof1, pTruth, nVars, iBestVar );
1392  return iBestVar;
1393 }
#define KIT_INFINITY
Definition: kit.h:173
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
Definition: kitTruth.c:327
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthChangePhase ( unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Changes phase of the function w.r.t. one variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 1259 of file kitTruth.c.

1260 {
1261  int nWords = Kit_TruthWordNum( nVars );
1262  int i, k, Step;
1263  unsigned Temp;
1264 
1265  assert( iVar < nVars );
1266  switch ( iVar )
1267  {
1268  case 0:
1269  for ( i = 0; i < nWords; i++ )
1270  pTruth[i] = ((pTruth[i] & 0x55555555) << 1) | ((pTruth[i] & 0xAAAAAAAA) >> 1);
1271  return;
1272  case 1:
1273  for ( i = 0; i < nWords; i++ )
1274  pTruth[i] = ((pTruth[i] & 0x33333333) << 2) | ((pTruth[i] & 0xCCCCCCCC) >> 2);
1275  return;
1276  case 2:
1277  for ( i = 0; i < nWords; i++ )
1278  pTruth[i] = ((pTruth[i] & 0x0F0F0F0F) << 4) | ((pTruth[i] & 0xF0F0F0F0) >> 4);
1279  return;
1280  case 3:
1281  for ( i = 0; i < nWords; i++ )
1282  pTruth[i] = ((pTruth[i] & 0x00FF00FF) << 8) | ((pTruth[i] & 0xFF00FF00) >> 8);
1283  return;
1284  case 4:
1285  for ( i = 0; i < nWords; i++ )
1286  pTruth[i] = ((pTruth[i] & 0x0000FFFF) << 16) | ((pTruth[i] & 0xFFFF0000) >> 16);
1287  return;
1288  default:
1289  Step = (1 << (iVar - 5));
1290  for ( k = 0; k < nWords; k += 2*Step )
1291  {
1292  for ( i = 0; i < Step; i++ )
1293  {
1294  Temp = pTruth[i];
1295  pTruth[i] = pTruth[Step+i];
1296  pTruth[Step+i] = Temp;
1297  }
1298  pTruth += 2*Step;
1299  }
1300  return;
1301  }
1302 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
static void Kit_TruthClear ( unsigned *  pOut,
int  nVars 
)
inlinestatic

Definition at line 361 of file kit.h.

362 {
363  int w;
364  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
365  pOut[w] = 0;
366 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
void Kit_TruthCofactor0 ( unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Computes negative cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 368 of file kitTruth.c.

369 {
370  int nWords = Kit_TruthWordNum( nVars );
371  int i, k, Step;
372 
373  assert( iVar < nVars );
374  switch ( iVar )
375  {
376  case 0:
377  for ( i = 0; i < nWords; i++ )
378  pTruth[i] = (pTruth[i] & 0x55555555) | ((pTruth[i] & 0x55555555) << 1);
379  return;
380  case 1:
381  for ( i = 0; i < nWords; i++ )
382  pTruth[i] = (pTruth[i] & 0x33333333) | ((pTruth[i] & 0x33333333) << 2);
383  return;
384  case 2:
385  for ( i = 0; i < nWords; i++ )
386  pTruth[i] = (pTruth[i] & 0x0F0F0F0F) | ((pTruth[i] & 0x0F0F0F0F) << 4);
387  return;
388  case 3:
389  for ( i = 0; i < nWords; i++ )
390  pTruth[i] = (pTruth[i] & 0x00FF00FF) | ((pTruth[i] & 0x00FF00FF) << 8);
391  return;
392  case 4:
393  for ( i = 0; i < nWords; i++ )
394  pTruth[i] = (pTruth[i] & 0x0000FFFF) | ((pTruth[i] & 0x0000FFFF) << 16);
395  return;
396  default:
397  Step = (1 << (iVar - 5));
398  for ( k = 0; k < nWords; k += 2*Step )
399  {
400  for ( i = 0; i < Step; i++ )
401  pTruth[Step+i] = pTruth[i];
402  pTruth += 2*Step;
403  }
404  return;
405  }
406 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthCofactor0New ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Computes positive cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 521 of file kitTruth.c.

522 {
523  int nWords = Kit_TruthWordNum( nVars );
524  int i, k, Step;
525 
526  assert( iVar < nVars );
527  switch ( iVar )
528  {
529  case 0:
530  for ( i = 0; i < nWords; i++ )
531  pOut[i] = (pIn[i] & 0x55555555) | ((pIn[i] & 0x55555555) << 1);
532  return;
533  case 1:
534  for ( i = 0; i < nWords; i++ )
535  pOut[i] = (pIn[i] & 0x33333333) | ((pIn[i] & 0x33333333) << 2);
536  return;
537  case 2:
538  for ( i = 0; i < nWords; i++ )
539  pOut[i] = (pIn[i] & 0x0F0F0F0F) | ((pIn[i] & 0x0F0F0F0F) << 4);
540  return;
541  case 3:
542  for ( i = 0; i < nWords; i++ )
543  pOut[i] = (pIn[i] & 0x00FF00FF) | ((pIn[i] & 0x00FF00FF) << 8);
544  return;
545  case 4:
546  for ( i = 0; i < nWords; i++ )
547  pOut[i] = (pIn[i] & 0x0000FFFF) | ((pIn[i] & 0x0000FFFF) << 16);
548  return;
549  default:
550  Step = (1 << (iVar - 5));
551  for ( k = 0; k < nWords; k += 2*Step )
552  {
553  for ( i = 0; i < Step; i++ )
554  pOut[i] = pOut[Step+i] = pIn[i];
555  pIn += 2*Step;
556  pOut += 2*Step;
557  }
558  return;
559  }
560 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthCofactor1 ( unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Computes positive cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 470 of file kitTruth.c.

471 {
472  int nWords = Kit_TruthWordNum( nVars );
473  int i, k, Step;
474 
475  assert( iVar < nVars );
476  switch ( iVar )
477  {
478  case 0:
479  for ( i = 0; i < nWords; i++ )
480  pTruth[i] = (pTruth[i] & 0xAAAAAAAA) | ((pTruth[i] & 0xAAAAAAAA) >> 1);
481  return;
482  case 1:
483  for ( i = 0; i < nWords; i++ )
484  pTruth[i] = (pTruth[i] & 0xCCCCCCCC) | ((pTruth[i] & 0xCCCCCCCC) >> 2);
485  return;
486  case 2:
487  for ( i = 0; i < nWords; i++ )
488  pTruth[i] = (pTruth[i] & 0xF0F0F0F0) | ((pTruth[i] & 0xF0F0F0F0) >> 4);
489  return;
490  case 3:
491  for ( i = 0; i < nWords; i++ )
492  pTruth[i] = (pTruth[i] & 0xFF00FF00) | ((pTruth[i] & 0xFF00FF00) >> 8);
493  return;
494  case 4:
495  for ( i = 0; i < nWords; i++ )
496  pTruth[i] = (pTruth[i] & 0xFFFF0000) | ((pTruth[i] & 0xFFFF0000) >> 16);
497  return;
498  default:
499  Step = (1 << (iVar - 5));
500  for ( k = 0; k < nWords; k += 2*Step )
501  {
502  for ( i = 0; i < Step; i++ )
503  pTruth[i] = pTruth[Step+i];
504  pTruth += 2*Step;
505  }
506  return;
507  }
508 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthCofactor1New ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Computes positive cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 573 of file kitTruth.c.

574 {
575  int nWords = Kit_TruthWordNum( nVars );
576  int i, k, Step;
577 
578  assert( iVar < nVars );
579  switch ( iVar )
580  {
581  case 0:
582  for ( i = 0; i < nWords; i++ )
583  pOut[i] = (pIn[i] & 0xAAAAAAAA) | ((pIn[i] & 0xAAAAAAAA) >> 1);
584  return;
585  case 1:
586  for ( i = 0; i < nWords; i++ )
587  pOut[i] = (pIn[i] & 0xCCCCCCCC) | ((pIn[i] & 0xCCCCCCCC) >> 2);
588  return;
589  case 2:
590  for ( i = 0; i < nWords; i++ )
591  pOut[i] = (pIn[i] & 0xF0F0F0F0) | ((pIn[i] & 0xF0F0F0F0) >> 4);
592  return;
593  case 3:
594  for ( i = 0; i < nWords; i++ )
595  pOut[i] = (pIn[i] & 0xFF00FF00) | ((pIn[i] & 0xFF00FF00) >> 8);
596  return;
597  case 4:
598  for ( i = 0; i < nWords; i++ )
599  pOut[i] = (pIn[i] & 0xFFFF0000) | ((pIn[i] & 0xFFFF0000) >> 16);
600  return;
601  default:
602  Step = (1 << (iVar - 5));
603  for ( k = 0; k < nWords; k += 2*Step )
604  {
605  for ( i = 0; i < Step; i++ )
606  pOut[i] = pOut[Step+i] = pIn[Step+i];
607  pIn += 2*Step;
608  pOut += 2*Step;
609  }
610  return;
611  }
612 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthCofSupports ( Vec_Int_t vBddDir,
Vec_Int_t vBddInv,
int  nVars,
Vec_Int_t vMemory,
unsigned *  puSupps 
)

Function********************************************************************

Synopsis [Compute BDD for the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 310 of file kitCloud.c.

311 {
312  Kit_Mux_t Mux;
313  unsigned * puSuppAll;
314  unsigned * pThis = NULL; // Suppress "might be used uninitialized"
315  unsigned * pFan0, * pFan1;
316  int i, v, Var, Entry, nSupps;
317  nSupps = 2 * nVars;
318 
319  // extend storage
320  if ( Vec_IntSize( vMemory ) < nSupps * Vec_IntSize(vBddDir) )
321  Vec_IntGrow( vMemory, nSupps * Vec_IntSize(vBddDir) );
322  puSuppAll = (unsigned *)Vec_IntArray( vMemory );
323  // clear storage for the const node
324  memset( puSuppAll, 0, sizeof(unsigned) * nSupps );
325  // compute supports from nodes
326  Vec_IntForEachEntryStart( vBddDir, Entry, i, 1 )
327  {
328  Mux = Kit_Int2Mux(Entry);
329  Var = nVars - 1 - Mux.v;
330  pFan0 = puSuppAll + nSupps * Mux.e;
331  pFan1 = puSuppAll + nSupps * Mux.t;
332  pThis = puSuppAll + nSupps * i;
333  for ( v = 0; v < nSupps; v++ )
334  pThis[v] = pFan0[v] | pFan1[v] | (1<<Var);
335  assert( pFan0[2*Var + 0] == pFan0[2*Var + 1] );
336  assert( pFan1[2*Var + 0] == pFan1[2*Var + 1] );
337  pThis[2*Var + 0] = pFan0[2*Var + 0];// | pFan0[2*Var + 1];
338  pThis[2*Var + 1] = pFan1[2*Var + 0];// | pFan1[2*Var + 1];
339  }
340  // copy the result
341  memcpy( puSupps, pThis, sizeof(unsigned) * nSupps );
342  // compute the inverse
343 
344  // extend storage
345  if ( Vec_IntSize( vMemory ) < nSupps * Vec_IntSize(vBddInv) )
346  Vec_IntGrow( vMemory, nSupps * Vec_IntSize(vBddInv) );
347  puSuppAll = (unsigned *)Vec_IntArray( vMemory );
348  // clear storage for the const node
349  memset( puSuppAll, 0, sizeof(unsigned) * nSupps );
350  // compute supports from nodes
351  Vec_IntForEachEntryStart( vBddInv, Entry, i, 1 )
352  {
353  Mux = Kit_Int2Mux(Entry);
354 // Var = nVars - 1 - Mux.v;
355  Var = Mux.v;
356  pFan0 = puSuppAll + nSupps * Mux.e;
357  pFan1 = puSuppAll + nSupps * Mux.t;
358  pThis = puSuppAll + nSupps * i;
359  for ( v = 0; v < nSupps; v++ )
360  pThis[v] = pFan0[v] | pFan1[v] | (1<<Var);
361  assert( pFan0[2*Var + 0] == pFan0[2*Var + 1] );
362  assert( pFan1[2*Var + 0] == pFan1[2*Var + 1] );
363  pThis[2*Var + 0] = pFan0[2*Var + 0];// | pFan0[2*Var + 1];
364  pThis[2*Var + 1] = pFan1[2*Var + 0];// | pFan1[2*Var + 1];
365  }
366 
367  // merge supports
368  for ( Var = 0; Var < nSupps; Var++ )
369  puSupps[Var] = (puSupps[Var] & Kit_BitMask(Var/2)) | (pThis[Var] & ~Kit_BitMask(Var/2));
370 }
char * memset()
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
char * memcpy()
typedefABC_NAMESPACE_IMPL_START struct Kit_Mux_t_ Kit_Mux_t
DECLARATIONS ///.
Definition: kitCloud.c:31
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Kit_Mux_t Kit_Int2Mux(int m)
Definition: kitCloud.c:42
int Var
Definition: SolverTypes.h:42
#define assert(ex)
Definition: util_old.h:213
static unsigned Kit_BitMask(int nBits)
Definition: kit.h:225
unsigned* Kit_TruthCompose ( CloudManager dd,
unsigned *  pTruth,
int  nVars,
unsigned **  pInputs,
int  nVarsAll,
Vec_Ptr_t vStore,
Vec_Int_t vNodes 
)

Function*************************************************************

Synopsis [Computes composition of truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 263 of file kitCloud.c.

265 {
266  CloudNode * pFunc;
267  unsigned * pThis, * pFan0, * pFan1;
268  Kit_Mux_t Mux;
269  int i, Entry, RetValue;
270  // derive BDD from truth table
271  Cloud_Restart( dd );
272  pFunc = Kit_TruthToCloud( dd, pTruth, nVars );
273  // convert it into nodes
274  RetValue = Kit_CreateCloud( dd, pFunc, vNodes );
275  if ( RetValue == 0 )
276  printf( "Kit_TruthCompose(): Internal failure!!!\n" );
277  // verify the result
278 // pFan0 = Kit_CloudToTruth( vNodes, nVars, vStore, 0 );
279 // if ( !Kit_TruthIsEqual( pTruth, pFan0, nVars ) )
280 // printf( "Failed!\n" );
281  // compute truth table from the BDD
282  assert( Vec_IntSize(vNodes) <= Vec_PtrSize(vStore) );
283  pThis = (unsigned *)Vec_PtrEntry( vStore, 0 );
284  Kit_TruthFill( pThis, nVarsAll );
285  Vec_IntForEachEntryStart( vNodes, Entry, i, 1 )
286  {
287  Mux = Kit_Int2Mux(Entry);
288  pFan0 = (unsigned *)Vec_PtrEntry( vStore, Mux.e );
289  pFan1 = (unsigned *)Vec_PtrEntry( vStore, Mux.t );
290  pThis = (unsigned *)Vec_PtrEntry( vStore, i );
291  Kit_TruthMuxPhase( pThis, pFan0, pFan1, pInputs[nVars-1-Mux.v], nVarsAll, Mux.c );
292  }
293  // complement the result
294  if ( Mux.i )
295  Kit_TruthNot( pThis, pThis, nVarsAll );
296  return pThis;
297 }
int Kit_CreateCloud(CloudManager *dd, CloudNode *pFunc, Vec_Int_t *vNodes)
Definition: kitCloud.c:167
static void Kit_TruthFill(unsigned *pOut, int nVars)
Definition: kit.h:367
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Cloud_Restart(CloudManager *dd)
Definition: cloud.c:166
typedefABC_NAMESPACE_IMPL_START struct Kit_Mux_t_ Kit_Mux_t
DECLARATIONS ///.
Definition: kitCloud.c:31
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
CloudNode * Kit_TruthToCloud(CloudManager *dd, unsigned *pTruth, int nVars)
Definition: kitCloud.c:148
static void Kit_TruthMuxPhase(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, unsigned *pCtrl, int nVars, int fComp0)
Definition: kit.h:463
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Kit_Mux_t Kit_Int2Mux(int m)
Definition: kitCloud.c:42
#define assert(ex)
Definition: util_old.h:213
static void Kit_TruthCopy ( unsigned *  pOut,
unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 355 of file kit.h.

356 {
357  int w;
358  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
359  pOut[w] = pIn[w];
360 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthCountOnes ( unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 251 of file kit.h.

252 {
253  int w, Counter = 0;
254  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
255  Counter += Kit_WordCountOnes(pIn[w]);
256  return Counter;
257 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Counter
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
void Kit_TruthCountOnesInCofs ( unsigned *  pTruth,
int  nVars,
int *  pStore 
)

Function*************************************************************

Synopsis [Counts the number of 1's in each cofactor.]

Description [The resulting numbers are stored in the array of ints, whose length is 2*nVars. The number of 1's is counted in a different space than the original function. For example, if the function depends on k variables, the cofactors are assumed to depend on k-1 variables.]

SideEffects []

SeeAlso []

Definition at line 1410 of file kitTruth.c.

1411 {
1412  int nWords = Kit_TruthWordNum( nVars );
1413  int i, k, Counter;
1414  memset( pStore, 0, sizeof(int) * 2 * nVars );
1415  if ( nVars <= 5 )
1416  {
1417  if ( nVars > 0 )
1418  {
1419  pStore[2*0+0] = Kit_WordCountOnes( pTruth[0] & 0x55555555 );
1420  pStore[2*0+1] = Kit_WordCountOnes( pTruth[0] & 0xAAAAAAAA );
1421  }
1422  if ( nVars > 1 )
1423  {
1424  pStore[2*1+0] = Kit_WordCountOnes( pTruth[0] & 0x33333333 );
1425  pStore[2*1+1] = Kit_WordCountOnes( pTruth[0] & 0xCCCCCCCC );
1426  }
1427  if ( nVars > 2 )
1428  {
1429  pStore[2*2+0] = Kit_WordCountOnes( pTruth[0] & 0x0F0F0F0F );
1430  pStore[2*2+1] = Kit_WordCountOnes( pTruth[0] & 0xF0F0F0F0 );
1431  }
1432  if ( nVars > 3 )
1433  {
1434  pStore[2*3+0] = Kit_WordCountOnes( pTruth[0] & 0x00FF00FF );
1435  pStore[2*3+1] = Kit_WordCountOnes( pTruth[0] & 0xFF00FF00 );
1436  }
1437  if ( nVars > 4 )
1438  {
1439  pStore[2*4+0] = Kit_WordCountOnes( pTruth[0] & 0x0000FFFF );
1440  pStore[2*4+1] = Kit_WordCountOnes( pTruth[0] & 0xFFFF0000 );
1441  }
1442  return;
1443  }
1444  // nVars >= 6
1445  // count 1's for all other variables
1446  for ( k = 0; k < nWords; k++ )
1447  {
1448  Counter = Kit_WordCountOnes( pTruth[k] );
1449  for ( i = 5; i < nVars; i++ )
1450  if ( k & (1 << (i-5)) )
1451  pStore[2*i+1] += Counter;
1452  else
1453  pStore[2*i+0] += Counter;
1454  }
1455  // count 1's for the first five variables
1456  for ( k = 0; k < nWords/2; k++ )
1457  {
1458  pStore[2*0+0] += Kit_WordCountOnes( (pTruth[0] & 0x55555555) | ((pTruth[1] & 0x55555555) << 1) );
1459  pStore[2*0+1] += Kit_WordCountOnes( (pTruth[0] & 0xAAAAAAAA) | ((pTruth[1] & 0xAAAAAAAA) >> 1) );
1460  pStore[2*1+0] += Kit_WordCountOnes( (pTruth[0] & 0x33333333) | ((pTruth[1] & 0x33333333) << 2) );
1461  pStore[2*1+1] += Kit_WordCountOnes( (pTruth[0] & 0xCCCCCCCC) | ((pTruth[1] & 0xCCCCCCCC) >> 2) );
1462  pStore[2*2+0] += Kit_WordCountOnes( (pTruth[0] & 0x0F0F0F0F) | ((pTruth[1] & 0x0F0F0F0F) << 4) );
1463  pStore[2*2+1] += Kit_WordCountOnes( (pTruth[0] & 0xF0F0F0F0) | ((pTruth[1] & 0xF0F0F0F0) >> 4) );
1464  pStore[2*3+0] += Kit_WordCountOnes( (pTruth[0] & 0x00FF00FF) | ((pTruth[1] & 0x00FF00FF) << 8) );
1465  pStore[2*3+1] += Kit_WordCountOnes( (pTruth[0] & 0xFF00FF00) | ((pTruth[1] & 0xFF00FF00) >> 8) );
1466  pStore[2*4+0] += Kit_WordCountOnes( (pTruth[0] & 0x0000FFFF) | ((pTruth[1] & 0x0000FFFF) << 16) );
1467  pStore[2*4+1] += Kit_WordCountOnes( (pTruth[0] & 0xFFFF0000) | ((pTruth[1] & 0xFFFF0000) >> 16) );
1468  pTruth += 2;
1469  }
1470 }
char * memset()
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
static int Counter
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
void Kit_TruthCountOnesInCofs0 ( unsigned *  pTruth,
int  nVars,
int *  pStore 
)

Function*************************************************************

Synopsis [Counts the number of 1's in each negative cofactor.]

Description [The resulting numbers are stored in the array of ints, whose length is nVars. The number of 1's is counted in a different space than the original function. For example, if the function depends on k variables, the cofactors are assumed to depend on k-1 variables.]

SideEffects []

SeeAlso []

Definition at line 1486 of file kitTruth.c.

1487 {
1488  int nWords = Kit_TruthWordNum( nVars );
1489  int i, k, Counter;
1490  memset( pStore, 0, sizeof(int) * nVars );
1491  if ( nVars <= 5 )
1492  {
1493  if ( nVars > 0 )
1494  pStore[0] = Kit_WordCountOnes( pTruth[0] & 0x55555555 );
1495  if ( nVars > 1 )
1496  pStore[1] = Kit_WordCountOnes( pTruth[0] & 0x33333333 );
1497  if ( nVars > 2 )
1498  pStore[2] = Kit_WordCountOnes( pTruth[0] & 0x0F0F0F0F );
1499  if ( nVars > 3 )
1500  pStore[3] = Kit_WordCountOnes( pTruth[0] & 0x00FF00FF );
1501  if ( nVars > 4 )
1502  pStore[4] = Kit_WordCountOnes( pTruth[0] & 0x0000FFFF );
1503  return;
1504  }
1505  // nVars >= 6
1506  // count 1's for all other variables
1507  for ( k = 0; k < nWords; k++ )
1508  {
1509  Counter = Kit_WordCountOnes( pTruth[k] );
1510  for ( i = 5; i < nVars; i++ )
1511  if ( (k & (1 << (i-5))) == 0 )
1512  pStore[i] += Counter;
1513  }
1514  // count 1's for the first five variables
1515  for ( k = 0; k < nWords/2; k++ )
1516  {
1517  pStore[0] += Kit_WordCountOnes( (pTruth[0] & 0x55555555) | ((pTruth[1] & 0x55555555) << 1) );
1518  pStore[1] += Kit_WordCountOnes( (pTruth[0] & 0x33333333) | ((pTruth[1] & 0x33333333) << 2) );
1519  pStore[2] += Kit_WordCountOnes( (pTruth[0] & 0x0F0F0F0F) | ((pTruth[1] & 0x0F0F0F0F) << 4) );
1520  pStore[3] += Kit_WordCountOnes( (pTruth[0] & 0x00FF00FF) | ((pTruth[1] & 0x00FF00FF) << 8) );
1521  pStore[4] += Kit_WordCountOnes( (pTruth[0] & 0x0000FFFF) | ((pTruth[1] & 0x0000FFFF) << 16) );
1522  pTruth += 2;
1523  }
1524 }
char * memset()
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
static int Counter
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
void Kit_TruthCountOnesInCofsSlow ( unsigned *  pTruth,
int  nVars,
int *  pStore,
unsigned *  pAux 
)

Function*************************************************************

Synopsis [Counts the number of 1's in each cofactor.]

Description [Verifies the above procedure.]

SideEffects []

SeeAlso []

Definition at line 1537 of file kitTruth.c.

1538 {
1539  int i;
1540  for ( i = 0; i < nVars; i++ )
1541  {
1542  Kit_TruthCofactor0New( pAux, pTruth, nVars, i );
1543  pStore[2*i+0] = Kit_TruthCountOnes( pAux, nVars ) / 2;
1544  Kit_TruthCofactor1New( pAux, pTruth, nVars, i );
1545  pStore[2*i+1] = Kit_TruthCountOnes( pAux, nVars ) / 2;
1546  }
1547 }
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
static int Kit_TruthCountOnes(unsigned *pIn, int nVars)
Definition: kit.h:251
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
char* Kit_TruthDumpToFile ( unsigned *  pTruth,
int  nVars,
int  nFile 
)

Function*************************************************************

Synopsis [Dumps truth table into a file.]

Description [Generates script file for reading into ABC.]

SideEffects []

SeeAlso []

Definition at line 2004 of file kitTruth.c.

2005 {
2006  static char pFileName[100];
2007  FILE * pFile;
2008  sprintf( pFileName, "tt\\s%04d", nFile );
2009  pFile = fopen( pFileName, "w" );
2010  fprintf( pFile, "rt " );
2011  Kit_PrintHexadecimal( pFile, pTruth, nVars );
2012  fprintf( pFile, "; bdd; sop; ps\n" );
2013  fclose( pFile );
2014  return pFileName;
2015 }
void Kit_PrintHexadecimal(FILE *pFile, unsigned Sign[], int nVars)
Definition: kitTruth.c:1939
char * sprintf()
void Kit_TruthExist ( unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Existentially quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 684 of file kitTruth.c.

685 {
686  int nWords = Kit_TruthWordNum( nVars );
687  int i, k, Step;
688 
689  assert( iVar < nVars );
690  switch ( iVar )
691  {
692  case 0:
693  for ( i = 0; i < nWords; i++ )
694  pTruth[i] |= ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
695  return;
696  case 1:
697  for ( i = 0; i < nWords; i++ )
698  pTruth[i] |= ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
699  return;
700  case 2:
701  for ( i = 0; i < nWords; i++ )
702  pTruth[i] |= ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
703  return;
704  case 3:
705  for ( i = 0; i < nWords; i++ )
706  pTruth[i] |= ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
707  return;
708  case 4:
709  for ( i = 0; i < nWords; i++ )
710  pTruth[i] |= ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
711  return;
712  default:
713  Step = (1 << (iVar - 5));
714  for ( k = 0; k < nWords; k += 2*Step )
715  {
716  for ( i = 0; i < Step; i++ )
717  {
718  pTruth[i] |= pTruth[Step+i];
719  pTruth[Step+i] = pTruth[i];
720  }
721  pTruth += 2*Step;
722  }
723  return;
724  }
725 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthExistNew ( unsigned *  pRes,
unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Existentially quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 738 of file kitTruth.c.

739 {
740  int nWords = Kit_TruthWordNum( nVars );
741  int i, k, Step;
742 
743  assert( iVar < nVars );
744  switch ( iVar )
745  {
746  case 0:
747  for ( i = 0; i < nWords; i++ )
748  pRes[i] = pTruth[i] | ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
749  return;
750  case 1:
751  for ( i = 0; i < nWords; i++ )
752  pRes[i] = pTruth[i] | ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
753  return;
754  case 2:
755  for ( i = 0; i < nWords; i++ )
756  pRes[i] = pTruth[i] | ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
757  return;
758  case 3:
759  for ( i = 0; i < nWords; i++ )
760  pRes[i] = pTruth[i] | ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
761  return;
762  case 4:
763  for ( i = 0; i < nWords; i++ )
764  pRes[i] = pTruth[i] | ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
765  return;
766  default:
767  Step = (1 << (iVar - 5));
768  for ( k = 0; k < nWords; k += 2*Step )
769  {
770  for ( i = 0; i < Step; i++ )
771  {
772  pRes[i] = pTruth[i] | pTruth[Step+i];
773  pRes[Step+i] = pRes[i];
774  }
775  pRes += 2*Step;
776  pTruth += 2*Step;
777  }
778  return;
779  }
780 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthExistSet ( unsigned *  pRes,
unsigned *  pTruth,
int  nVars,
unsigned  uMask 
)

Function*************************************************************

Synopsis [Existantially quantifies the set of variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 793 of file kitTruth.c.

794 {
795  int v;
796  Kit_TruthCopy( pRes, pTruth, nVars );
797  for ( v = 0; v < nVars; v++ )
798  if ( uMask & (1 << v) )
799  Kit_TruthExist( pRes, nVars, v );
800 }
void Kit_TruthExist(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:684
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static void Kit_TruthFill ( unsigned *  pOut,
int  nVars 
)
inlinestatic

Definition at line 367 of file kit.h.

368 {
369  int w;
370  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
371  pOut[w] = ~(unsigned)0;
372 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthFindFirstBit ( unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 258 of file kit.h.

259 {
260  int w;
261  for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
262  if ( pIn[w] )
263  return 32*w + Kit_WordFindFirstBit(pIn[w]);
264  return -1;
265 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_WordFindFirstBit(unsigned uWord)
Definition: kit.h:231
static int Kit_TruthFindFirstZero ( unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 266 of file kit.h.

267 {
268  int w;
269  for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
270  if ( ~pIn[w] )
271  return 32*w + Kit_WordFindFirstBit(~pIn[w]);
272  return -1;
273 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_WordFindFirstBit(unsigned uWord)
Definition: kit.h:231
void Kit_TruthForall ( unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Unversally quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 813 of file kitTruth.c.

814 {
815  int nWords = Kit_TruthWordNum( nVars );
816  int i, k, Step;
817 
818  assert( iVar < nVars );
819  switch ( iVar )
820  {
821  case 0:
822  for ( i = 0; i < nWords; i++ )
823  pTruth[i] &= ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
824  return;
825  case 1:
826  for ( i = 0; i < nWords; i++ )
827  pTruth[i] &= ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
828  return;
829  case 2:
830  for ( i = 0; i < nWords; i++ )
831  pTruth[i] &= ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
832  return;
833  case 3:
834  for ( i = 0; i < nWords; i++ )
835  pTruth[i] &= ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
836  return;
837  case 4:
838  for ( i = 0; i < nWords; i++ )
839  pTruth[i] &= ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
840  return;
841  default:
842  Step = (1 << (iVar - 5));
843  for ( k = 0; k < nWords; k += 2*Step )
844  {
845  for ( i = 0; i < Step; i++ )
846  {
847  pTruth[i] &= pTruth[Step+i];
848  pTruth[Step+i] = pTruth[i];
849  }
850  pTruth += 2*Step;
851  }
852  return;
853  }
854 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthForallNew ( unsigned *  pRes,
unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Universally quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 867 of file kitTruth.c.

868 {
869  int nWords = Kit_TruthWordNum( nVars );
870  int i, k, Step;
871 
872  assert( iVar < nVars );
873  switch ( iVar )
874  {
875  case 0:
876  for ( i = 0; i < nWords; i++ )
877  pRes[i] = pTruth[i] & (((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1));
878  return;
879  case 1:
880  for ( i = 0; i < nWords; i++ )
881  pRes[i] = pTruth[i] & (((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2));
882  return;
883  case 2:
884  for ( i = 0; i < nWords; i++ )
885  pRes[i] = pTruth[i] & (((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4));
886  return;
887  case 3:
888  for ( i = 0; i < nWords; i++ )
889  pRes[i] = pTruth[i] & (((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8));
890  return;
891  case 4:
892  for ( i = 0; i < nWords; i++ )
893  pRes[i] = pTruth[i] & (((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16));
894  return;
895  default:
896  Step = (1 << (iVar - 5));
897  for ( k = 0; k < nWords; k += 2*Step )
898  {
899  for ( i = 0; i < Step; i++ )
900  {
901  pRes[i] = pTruth[i] & pTruth[Step+i];
902  pRes[Step+i] = pRes[i];
903  }
904  pRes += 2*Step;
905  pTruth += 2*Step;
906  }
907  return;
908  }
909 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthForallSet ( unsigned *  pRes,
unsigned *  pTruth,
int  nVars,
unsigned  uMask 
)

Function*************************************************************

Synopsis [Universally quantifies the set of variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 1048 of file kitTruth.c.

1049 {
1050  int v;
1051  Kit_TruthCopy( pRes, pTruth, nVars );
1052  for ( v = 0; v < nVars; v++ )
1053  if ( uMask & (1 << v) )
1054  Kit_TruthForall( pRes, nVars, v );
1055 }
void Kit_TruthForall(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:813
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static int Kit_TruthHasBit ( unsigned *  p,
int  Bit 
)
inlinestatic

Definition at line 229 of file kit.h.

229 { return (p[Bit>>5] & (1<<(Bit & 31))) > 0; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned Kit_TruthHash ( unsigned *  pIn,
int  nWords 
)

Function*************************************************************

Synopsis [Canonicize the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 1560 of file kitTruth.c.

1561 {
1562  // The 1,024 smallest prime numbers used to compute the hash value
1563  // http://www.math.utah.edu/~alfeld/math/primelist.html
1564  static int HashPrimes[1024] = { 2, 3, 5,
1565  7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
1566  101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
1567  193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,
1568  293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401,
1569  409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
1570  521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631,
1571  641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751,
1572  757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877,
1573  881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,
1574  1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091,
1575  1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193,
1576  1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,
1577  1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
1578  1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493,
1579  1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601,
1580  1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699,
1581  1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
1582  1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931,
1583  1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029,
1584  2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137,
1585  2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267,
1586  2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,
1587  2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459,
1588  2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593,
1589  2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693,
1590  2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791,
1591  2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903,
1592  2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023,
1593  3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167,
1594  3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271,
1595  3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373,
1596  3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511,
1597  3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607,
1598  3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709,
1599  3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833,
1600  3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931,
1601  3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057,
1602  4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177,
1603  4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283,
1604  4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423,
1605  4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547,
1606  4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657,
1607  4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789,
1608  4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931,
1609  4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011,
1610  5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147,
1611  5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279,
1612  5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413,
1613  5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507,
1614  5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647,
1615  5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743,
1616  5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857,
1617  5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007,
1618  6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121,
1619  6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247,
1620  6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343,
1621  6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473,
1622  6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607,
1623  6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733,
1624  6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857,
1625  6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971,
1626  6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103,
1627  7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229,
1628  7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369,
1629  7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517,
1630  7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603,
1631  7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723,
1632  7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873,
1633  7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009,
1634  8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123,
1635  8147, 8161 };
1636  int i;
1637  unsigned uHashKey;
1638  assert( nWords <= 1024 );
1639  uHashKey = 0;
1640  for ( i = 0; i < nWords; i++ )
1641  uHashKey ^= HashPrimes[i] * pIn[i];
1642  return uHashKey;
1643 }
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
static int Kit_TruthIsConst0 ( unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 315 of file kit.h.

316 {
317  int w;
318  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
319  if ( pIn[w] )
320  return 0;
321  return 1;
322 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsConst1 ( unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 323 of file kit.h.

324 {
325  int w;
326  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
327  if ( pIn[w] != ~(unsigned)0 )
328  return 0;
329  return 1;
330 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsDisjoint ( unsigned *  pIn1,
unsigned *  pIn2,
int  nVars 
)
inlinestatic

Definition at line 339 of file kit.h.

340 {
341  int w;
342  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
343  if ( pIn1[w] & pIn2[w] )
344  return 0;
345  return 1;
346 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsDisjoint3 ( unsigned *  pIn1,
unsigned *  pIn2,
unsigned *  pIn3,
int  nVars 
)
inlinestatic

Definition at line 347 of file kit.h.

348 {
349  int w;
350  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
351  if ( pIn1[w] & pIn2[w] & pIn3[w] )
352  return 0;
353  return 1;
354 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsEqual ( unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 274 of file kit.h.

275 {
276  int w;
277  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
278  if ( pIn0[w] != pIn1[w] )
279  return 0;
280  return 1;
281 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsEqualWithCare ( unsigned *  pIn0,
unsigned *  pIn1,
unsigned *  pCare,
int  nVars 
)
inlinestatic

Definition at line 282 of file kit.h.

283 {
284  int w;
285  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
286  if ( (pIn0[w] & pCare[w]) != (pIn1[w] & pCare[w]) )
287  return 0;
288  return 1;
289 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsEqualWithPhase ( unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 298 of file kit.h.

299 {
300  int w;
301  if ( (pIn0[0] & 1) == (pIn1[0] & 1) )
302  {
303  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
304  if ( pIn0[w] != pIn1[w] )
305  return 0;
306  }
307  else
308  {
309  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
310  if ( pIn0[w] != ~pIn1[w] )
311  return 0;
312  }
313  return 1;
314 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static int Kit_TruthIsImply ( unsigned *  pIn1,
unsigned *  pIn2,
int  nVars 
)
inlinestatic

Definition at line 331 of file kit.h.

332 {
333  int w;
334  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
335  if ( pIn1[w] & ~pIn2[w] )
336  return 0;
337  return 1;
338 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int Kit_TruthIsop ( unsigned *  puTruth,
int  nVars,
Vec_Int_t vMemory,
int  fTryBoth 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Computes ISOP from TT.]

Description [Returns the cover in vMemory. Uses the rest of array in vMemory as an intermediate memory storage. Returns the cover with -1 cubes, if the the computation exceeded the memory limit (KIT_ISOP_MEM_LIMIT words of intermediate data).]

SideEffects []

SeeAlso []

Definition at line 55 of file kitIsop.c.

56 {
57  Kit_Sop_t cRes, * pcRes = &cRes;
58  Kit_Sop_t cRes2, * pcRes2 = &cRes2;
59  unsigned * pResult;
60  int RetValue = 0;
61  assert( nVars >= 0 && nVars <= 16 );
62  // if nVars < 5, make sure it does not depend on those vars
63 // for ( i = nVars; i < 5; i++ )
64 // assert( !Kit_TruthVarInSupport(puTruth, 5, i) );
65  // prepare memory manager
66  Vec_IntClear( vMemory );
67  Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
68  // compute ISOP for the direct polarity
69  pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes, vMemory );
70  if ( pcRes->nCubes == -1 )
71  {
72  vMemory->nSize = -1;
73  return -1;
74  }
75  assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
76  if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
77  {
78  vMemory->pArray[0] = 0;
79  Vec_IntShrink( vMemory, pcRes->nCubes );
80  return 0;
81  }
82  if ( fTryBoth )
83  {
84  // compute ISOP for the complemented polarity
85  Kit_TruthNot( puTruth, puTruth, nVars );
86  pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes2, vMemory );
87  if ( pcRes2->nCubes >= 0 )
88  {
89  assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
90  if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
91  {
92  RetValue = 1;
93  pcRes = pcRes2;
94  }
95  }
96  Kit_TruthNot( puTruth, puTruth, nVars );
97  }
98 // printf( "%d ", vMemory->nSize );
99  // move the cover representation to the beginning of the memory buffer
100  memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
101  Vec_IntShrink( vMemory, pcRes->nCubes );
102  return RetValue;
103 }
#define KIT_ISOP_MEM_LIMIT
DECLARATIONS ///.
Definition: kitIsop.c:31
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
char * memmove()
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
Definition: kit.h:51
static unsigned * Kit_TruthIsop_rec(unsigned *puOn, unsigned *puOnDc, int nVars, Kit_Sop_t *pcRes, Vec_Int_t *vStore)
Definition: kitIsop.c:145
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Kit_TruthIsOpposite ( unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 290 of file kit.h.

291 {
292  int w;
293  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
294  if ( pIn0[w] != ~pIn1[w] )
295  return 0;
296  return 1;
297 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
void Kit_TruthIsopPrint ( unsigned *  puTruth,
int  nVars,
Vec_Int_t vMemory,
int  fTryBoth 
)

Definition at line 128 of file kitIsop.c.

129 {
130  int fCompl = Kit_TruthIsop( puTruth, nVars, vCover, fTryBoth );
131  Kit_TruthIsopPrintCover( vCover, nVars, fCompl );
132 }
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
Definition: kitIsop.c:104
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
void Kit_TruthIsopPrintCover ( Vec_Int_t vCover,
int  nVars,
int  fCompl 
)

Definition at line 104 of file kitIsop.c.

105 {
106  int i, k, Entry, Literal;
107  if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0) )
108  {
109  printf( "Constant %d\n", Vec_IntSize(vCover) );
110  return;
111  }
112  Vec_IntForEachEntry( vCover, Entry, i )
113  {
114  for ( k = 0; k < nVars; k++ )
115  {
116  Literal = 3 & (Entry >> (k << 1));
117  if ( Literal == 1 ) // neg literal
118  printf( "0" );
119  else if ( Literal == 2 ) // pos literal
120  printf( "1" );
121  else if ( Literal == 0 )
122  printf( "-" );
123  else assert( 0 );
124  }
125  printf( " %d\n", !fCompl );
126  }
127 }
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void Kit_TruthIthVar ( unsigned *  pTruth,
int  nVars,
int  iVar 
)
inlinestatic

Definition at line 473 of file kit.h.

474 {
475  unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
476  int k, nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
477  if ( iVar < 5 )
478  {
479  for ( k = 0; k < nWords; k++ )
480  pTruth[k] = Masks[iVar];
481  }
482  else
483  {
484  for ( k = 0; k < nWords; k++ )
485  if ( k & (1 << (iVar-5)) )
486  pTruth[k] = ~(unsigned)0;
487  else
488  pTruth[k] = 0;
489  }
490 }
int nWords
Definition: abcNpn.c:127
int Kit_TruthMinCofSuppOverlap ( unsigned *  pTruth,
int  nVars,
int *  pVarMin 
)

Function*************************************************************

Synopsis [Computes minimum overlap in supports of cofactors.]

Description []

SideEffects []

SeeAlso []

Definition at line 1315 of file kitTruth.c.

1316 {
1317  static unsigned uCofactor[16];
1318  int i, ValueCur, ValueMin, VarMin;
1319  unsigned uSupp0, uSupp1;
1320  int nVars0, nVars1;
1321  assert( nVars <= 9 );
1322  ValueMin = 32;
1323  VarMin = -1;
1324  for ( i = 0; i < nVars; i++ )
1325  {
1326  // get negative cofactor
1327  Kit_TruthCopy( uCofactor, pTruth, nVars );
1328  Kit_TruthCofactor0( uCofactor, nVars, i );
1329  uSupp0 = Kit_TruthSupport( uCofactor, nVars );
1330  nVars0 = Kit_WordCountOnes( uSupp0 );
1331 //Kit_PrintBinary( stdout, &uSupp0, 8 ); printf( "\n" );
1332  // get positive cofactor
1333  Kit_TruthCopy( uCofactor, pTruth, nVars );
1334  Kit_TruthCofactor1( uCofactor, nVars, i );
1335  uSupp1 = Kit_TruthSupport( uCofactor, nVars );
1336  nVars1 = Kit_WordCountOnes( uSupp1 );
1337 //Kit_PrintBinary( stdout, &uSupp1, 8 ); printf( "\n" );
1338  // get the number of common vars
1339  ValueCur = Kit_WordCountOnes( uSupp0 & uSupp1 );
1340  if ( ValueMin > ValueCur && nVars0 <= 5 && nVars1 <= 5 )
1341  {
1342  ValueMin = ValueCur;
1343  VarMin = i;
1344  }
1345  if ( ValueMin == 0 )
1346  break;
1347  }
1348  if ( pVarMin )
1349  *pVarMin = VarMin;
1350  return ValueMin;
1351 }
void Kit_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:470
void Kit_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:368
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
#define assert(ex)
Definition: util_old.h:213
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
static void Kit_TruthMux ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
unsigned *  pCtrl,
int  nVars 
)
inlinestatic

Definition at line 457 of file kit.h.

458 {
459  int w;
460  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
461  pOut[w] = (pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
462 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Kit_TruthMuxPhase ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
unsigned *  pCtrl,
int  nVars,
int  fComp0 
)
inlinestatic

Definition at line 463 of file kit.h.

464 {
465  int w;
466  if ( fComp0 )
467  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
468  pOut[w] = (~pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
469  else
470  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
471  pOut[w] = (pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
472 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
void Kit_TruthMuxVar ( unsigned *  pOut,
unsigned *  pCof0,
unsigned *  pCof1,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Multiplexes two functions with the given variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 1069 of file kitTruth.c.

1070 {
1071  int nWords = Kit_TruthWordNum( nVars );
1072  int i, k, Step;
1073 
1074  assert( iVar < nVars );
1075  switch ( iVar )
1076  {
1077  case 0:
1078  for ( i = 0; i < nWords; i++ )
1079  pOut[i] = (pCof0[i] & 0x55555555) | (pCof1[i] & 0xAAAAAAAA);
1080  return;
1081  case 1:
1082  for ( i = 0; i < nWords; i++ )
1083  pOut[i] = (pCof0[i] & 0x33333333) | (pCof1[i] & 0xCCCCCCCC);
1084  return;
1085  case 2:
1086  for ( i = 0; i < nWords; i++ )
1087  pOut[i] = (pCof0[i] & 0x0F0F0F0F) | (pCof1[i] & 0xF0F0F0F0);
1088  return;
1089  case 3:
1090  for ( i = 0; i < nWords; i++ )
1091  pOut[i] = (pCof0[i] & 0x00FF00FF) | (pCof1[i] & 0xFF00FF00);
1092  return;
1093  case 4:
1094  for ( i = 0; i < nWords; i++ )
1095  pOut[i] = (pCof0[i] & 0x0000FFFF) | (pCof1[i] & 0xFFFF0000);
1096  return;
1097  default:
1098  Step = (1 << (iVar - 5));
1099  for ( k = 0; k < nWords; k += 2*Step )
1100  {
1101  for ( i = 0; i < Step; i++ )
1102  {
1103  pOut[i] = pCof0[i];
1104  pOut[Step+i] = pCof1[Step+i];
1105  }
1106  pOut += 2*Step;
1107  pCof0 += 2*Step;
1108  pCof1 += 2*Step;
1109  }
1110  return;
1111  }
1112 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthMuxVarPhase ( unsigned *  pOut,
unsigned *  pCof0,
unsigned *  pCof1,
int  nVars,
int  iVar,
int  fCompl0 
)

Function*************************************************************

Synopsis [Multiplexes two functions with the given variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 1125 of file kitTruth.c.

1126 {
1127  int nWords = Kit_TruthWordNum( nVars );
1128  int i, k, Step;
1129 
1130  if ( fCompl0 == 0 )
1131  {
1132  Kit_TruthMuxVar( pOut, pCof0, pCof1, nVars, iVar );
1133  return;
1134  }
1135 
1136  assert( iVar < nVars );
1137  switch ( iVar )
1138  {
1139  case 0:
1140  for ( i = 0; i < nWords; i++ )
1141  pOut[i] = (~pCof0[i] & 0x55555555) | (pCof1[i] & 0xAAAAAAAA);
1142  return;
1143  case 1:
1144  for ( i = 0; i < nWords; i++ )
1145  pOut[i] = (~pCof0[i] & 0x33333333) | (pCof1[i] & 0xCCCCCCCC);
1146  return;
1147  case 2:
1148  for ( i = 0; i < nWords; i++ )
1149  pOut[i] = (~pCof0[i] & 0x0F0F0F0F) | (pCof1[i] & 0xF0F0F0F0);
1150  return;
1151  case 3:
1152  for ( i = 0; i < nWords; i++ )
1153  pOut[i] = (~pCof0[i] & 0x00FF00FF) | (pCof1[i] & 0xFF00FF00);
1154  return;
1155  case 4:
1156  for ( i = 0; i < nWords; i++ )
1157  pOut[i] = (~pCof0[i] & 0x0000FFFF) | (pCof1[i] & 0xFFFF0000);
1158  return;
1159  default:
1160  Step = (1 << (iVar - 5));
1161  for ( k = 0; k < nWords; k += 2*Step )
1162  {
1163  for ( i = 0; i < Step; i++ )
1164  {
1165  pOut[i] = ~pCof0[i];
1166  pOut[Step+i] = pCof1[Step+i];
1167  }
1168  pOut += 2*Step;
1169  pCof0 += 2*Step;
1170  pCof1 += 2*Step;
1171  }
1172  return;
1173  }
1174 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
void Kit_TruthMuxVar(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
Definition: kitTruth.c:1069
#define assert(ex)
Definition: util_old.h:213
static void Kit_TruthNand ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 403 of file kit.h.

404 {
405  int w;
406  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
407  pOut[w] = ~(pIn0[w] & pIn1[w]);
408 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Kit_TruthNot ( unsigned *  pOut,
unsigned *  pIn,
int  nVars 
)
inlinestatic

Definition at line 373 of file kit.h.

374 {
375  int w;
376  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
377  pOut[w] = ~pIn[w];
378 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Kit_TruthOr ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 385 of file kit.h.

386 {
387  int w;
388  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
389  pOut[w] = pIn0[w] | pIn1[w];
390 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Kit_TruthOrPhase ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars,
int  fCompl0,
int  fCompl1 
)
inlinestatic

Definition at line 433 of file kit.h.

434 {
435  int w;
436  if ( fCompl0 && fCompl1 )
437  {
438  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
439  pOut[w] = ~(pIn0[w] & pIn1[w]);
440  }
441  else if ( fCompl0 && !fCompl1 )
442  {
443  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
444  pOut[w] = ~pIn0[w] | pIn1[w];
445  }
446  else if ( !fCompl0 && fCompl1 )
447  {
448  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
449  pOut[w] = pIn0[w] | ~pIn1[w];
450  }
451  else // if ( !fCompl0 && !fCompl1 )
452  {
453  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
454  pOut[w] = pIn0[w] | pIn1[w];
455  }
456 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
void Kit_TruthPermute ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
char *  pPerm,
int  fReturnIn 
)

Function*************************************************************

Synopsis [Implement give permutation.]

Description [The input and output truth tables are in pIn/pOut. The number of variables is nVars. Permutation is in pPerm.]

SideEffects [The input truth table is modified.]

SeeAlso []

Definition at line 233 of file kitTruth.c.

234 {
235  unsigned * pTemp;
236  int i, Temp, fChange, Counter = 0;
237  do {
238  fChange = 0;
239  for ( i = 0; i < nVars-1; i++ )
240  {
241  assert( pPerm[i] != pPerm[i+1] );
242  if ( pPerm[i] <= pPerm[i+1] )
243  continue;
244  Counter++;
245  fChange = 1;
246 
247  Temp = pPerm[i];
248  pPerm[i] = pPerm[i+1];
249  pPerm[i+1] = Temp;
250 
251  Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
252  pTemp = pIn; pIn = pOut; pOut = pTemp;
253  }
254  } while ( fChange );
255  if ( fReturnIn ^ !(Counter & 1) )
256  Kit_TruthCopy( pOut, pIn, nVars );
257 }
ABC_NAMESPACE_IMPL_START void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
DECLARATIONS ///.
Definition: kitTruth.c:46
static int Counter
static int pPerm[13719]
Definition: rwrTemp.c:32
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthPrintProfile ( unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Dumps truth table into a file.]

Description [Generates script file for reading into ABC.]

SideEffects []

SeeAlso []

Definition at line 2203 of file kitTruth.c.

2204 {
2205  unsigned uTruth[2];
2206  if ( nVars >= 6 )
2207  {
2208  Kit_TruthPrintProfile_int( pTruth, nVars );
2209  return;
2210  }
2211  assert( nVars >= 2 );
2212  uTruth[0] = pTruth[0];
2213  uTruth[1] = pTruth[0];
2214  Kit_TruthPrintProfile( uTruth, 6 );
2215 }
void Kit_TruthPrintProfile_int(unsigned *pTruth, int nVars)
Definition: kitTruth.c:2029
void Kit_TruthPrintProfile(unsigned *pTruth, int nVars)
Definition: kitTruth.c:2203
#define assert(ex)
Definition: util_old.h:213
unsigned Kit_TruthSemiCanonicize ( unsigned *  pInOut,
unsigned *  pAux,
int  nVars,
char *  pCanonPerm 
)

Function*************************************************************

Synopsis [Canonicize the truth table.]

Description [Returns the phase. ]

SideEffects []

SeeAlso []

Definition at line 1657 of file kitTruth.c.

1658 {
1659  int pStore[32];
1660  unsigned * pIn = pInOut, * pOut = pAux, * pTemp;
1661  int nWords = Kit_TruthWordNum( nVars );
1662  int i, Temp, fChange, Counter, nOnes;//, k, j, w, Limit;
1663  unsigned uCanonPhase;
1664 
1665  // canonicize output
1666  uCanonPhase = 0;
1667  for ( i = 0; i < nVars; i++ )
1668  pCanonPerm[i] = i;
1669 
1670  nOnes = Kit_TruthCountOnes(pIn, nVars);
1671  //if(pIn[0] & 1)
1672  if ( (nOnes > nWords * 16) )//|| ((nOnes == nWords * 16) && (pIn[0] & 1)) )
1673  {
1674  uCanonPhase |= (1 << nVars);
1675  Kit_TruthNot( pIn, pIn, nVars );
1676  }
1677 
1678  // collect the minterm counts
1679  Kit_TruthCountOnesInCofs( pIn, nVars, pStore );
1680 /*
1681  Kit_TruthCountOnesInCofsSlow( pIn, nVars, pStore2, pAux );
1682  for ( i = 0; i < 2*nVars; i++ )
1683  {
1684  assert( pStore[i] == pStore2[i] );
1685  }
1686 */
1687  // canonicize phase
1688  for ( i = 0; i < nVars; i++ )
1689  {
1690  if ( pStore[2*i+0] >= pStore[2*i+1] )
1691  continue;
1692  uCanonPhase |= (1 << i);
1693  Temp = pStore[2*i+0];
1694  pStore[2*i+0] = pStore[2*i+1];
1695  pStore[2*i+1] = Temp;
1696  Kit_TruthChangePhase( pIn, nVars, i );
1697  }
1698 
1699 // Kit_PrintHexadecimal( stdout, pIn, nVars );
1700 // printf( "\n" );
1701 
1702  // permute
1703  Counter = 0;
1704  do {
1705  fChange = 0;
1706  for ( i = 0; i < nVars-1; i++ )
1707  {
1708  if ( pStore[2*i] >= pStore[2*(i+1)] )
1709  continue;
1710  Counter++;
1711  fChange = 1;
1712 
1713  Temp = pCanonPerm[i];
1714  pCanonPerm[i] = pCanonPerm[i+1];
1715  pCanonPerm[i+1] = Temp;
1716 
1717  Temp = pStore[2*i];
1718  pStore[2*i] = pStore[2*(i+1)];
1719  pStore[2*(i+1)] = Temp;
1720 
1721  Temp = pStore[2*i+1];
1722  pStore[2*i+1] = pStore[2*(i+1)+1];
1723  pStore[2*(i+1)+1] = Temp;
1724 
1725  // if the polarity of variables is different, swap them
1726  if ( ((uCanonPhase & (1 << i)) > 0) != ((uCanonPhase & (1 << (i+1))) > 0) )
1727  {
1728  uCanonPhase ^= (1 << i);
1729  uCanonPhase ^= (1 << (i+1));
1730  }
1731 
1732  Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
1733  pTemp = pIn; pIn = pOut; pOut = pTemp;
1734  }
1735  } while ( fChange );
1736 
1737 
1738 /*
1739  Extra_PrintBinary( stdout, &uCanonPhase, nVars+1 ); printf( " : " );
1740  for ( i = 0; i < nVars; i++ )
1741  printf( "%d=%d/%d ", pCanonPerm[i], pStore[2*i], pStore[2*i+1] );
1742  printf( " C = %d\n", Counter );
1743  Extra_PrintHexadecimal( stdout, pIn, nVars );
1744  printf( "\n" );
1745 */
1746 
1747 /*
1748  // process symmetric variable groups
1749  uSymms = 0;
1750  for ( i = 0; i < nVars-1; i++ )
1751  {
1752  if ( pStore[2*i] != pStore[2*(i+1)] ) // i and i+1 cannot be symmetric
1753  continue;
1754  if ( pStore[2*i] != pStore[2*i+1] )
1755  continue;
1756  if ( Kit_TruthVarsSymm( pIn, nVars, i, i+1 ) )
1757  continue;
1758  if ( Kit_TruthVarsAntiSymm( pIn, nVars, i, i+1 ) )
1759  Kit_TruthChangePhase( pIn, nVars, i+1 );
1760  }
1761 */
1762 
1763 /*
1764  // process symmetric variable groups
1765  uSymms = 0;
1766  for ( i = 0; i < nVars-1; i++ )
1767  {
1768  if ( pStore[2*i] != pStore[2*(i+1)] ) // i and i+1 cannot be symmetric
1769  continue;
1770  // i and i+1 can be symmetric
1771  // find the end of this group
1772  for ( k = i+1; k < nVars; k++ )
1773  if ( pStore[2*i] != pStore[2*k] )
1774  break;
1775  Limit = k;
1776  assert( i < Limit-1 );
1777  // go through the variables in this group
1778  for ( j = i + 1; j < Limit; j++ )
1779  {
1780  // check symmetry
1781  if ( Kit_TruthVarsSymm( pIn, nVars, i, j ) )
1782  {
1783  uSymms |= (1 << j);
1784  continue;
1785  }
1786  // they are phase-unknown
1787  if ( pStore[2*i] == pStore[2*i+1] )
1788  {
1789  if ( Kit_TruthVarsAntiSymm( pIn, nVars, i, j ) )
1790  {
1791  Kit_TruthChangePhase( pIn, nVars, j );
1792  uCanonPhase ^= (1 << j);
1793  uSymms |= (1 << j);
1794  continue;
1795  }
1796  }
1797 
1798  // they are not symmetric - move j as far as it goes in the group
1799  for ( k = j; k < Limit-1; k++ )
1800  {
1801  Counter++;
1802 
1803  Temp = pCanonPerm[k];
1804  pCanonPerm[k] = pCanonPerm[k+1];
1805  pCanonPerm[k+1] = Temp;
1806 
1807  assert( pStore[2*k] == pStore[2*(k+1)] );
1808  Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, k );
1809  pTemp = pIn; pIn = pOut; pOut = pTemp;
1810  }
1811  Limit--;
1812  j--;
1813  }
1814  i = Limit - 1;
1815  }
1816 */
1817 
1818  // swap if it was moved an even number of times
1819  if ( Counter & 1 )
1820  Kit_TruthCopy( pOut, pIn, nVars );
1821  return uCanonPhase;
1822 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
ABC_NAMESPACE_IMPL_START void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
DECLARATIONS ///.
Definition: kitTruth.c:46
int nWords
Definition: abcNpn.c:127
static int Kit_TruthCountOnes(unsigned *pIn, int nVars)
Definition: kit.h:251
static int Counter
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
void Kit_TruthChangePhase(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:1259
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
void Kit_TruthCountOnesInCofs(unsigned *pTruth, int nVars, int *pStore)
Definition: kitTruth.c:1410
static void Kit_TruthSetBit ( unsigned *  p,
int  Bit 
)
inlinestatic

Definition at line 227 of file kit.h.

227 { p[Bit>>5] |= (1<<(Bit & 31)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Kit_TruthSharp ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 397 of file kit.h.

398 {
399  int w;
400  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
401  pOut[w] = pIn0[w] & ~pIn1[w];
402 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
void Kit_TruthShrink ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
int  nVarsAll,
unsigned  Phase,
int  fReturnIn 
)

Function*************************************************************

Synopsis [Shrinks the truth table according to the phase.]

Description [The input and output truth tables are in pIn/pOut. The current number of variables is nVars. The total number of variables in nVarsAll. The last argument (Phase) shows what variables should remain.]

SideEffects [The input truth table is modified.]

SeeAlso []

Definition at line 200 of file kitTruth.c.

201 {
202  unsigned * pTemp;
203  int i, k, Var = 0, Counter = 0;
204  for ( i = 0; i < nVarsAll; i++ )
205  if ( Phase & (1 << i) )
206  {
207  for ( k = i-1; k >= Var; k-- )
208  {
209  Kit_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
210  pTemp = pIn; pIn = pOut; pOut = pTemp;
211  Counter++;
212  }
213  Var++;
214  }
215  assert( Var == nVars );
216  // swap if it was moved an even number of times
217  if ( fReturnIn ^ !(Counter & 1) )
218  Kit_TruthCopy( pOut, pIn, nVarsAll );
219 }
ABC_NAMESPACE_IMPL_START void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
DECLARATIONS ///.
Definition: kitTruth.c:46
static int Counter
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
int Var
Definition: SolverTypes.h:42
#define assert(ex)
Definition: util_old.h:213
void Kit_TruthStretch ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
int  nVarsAll,
unsigned  Phase,
int  fReturnIn 
)

Function*************************************************************

Synopsis [Expands the truth table according to the phase.]

Description [The input and output truth tables are in pIn/pOut. The current number of variables is nVars. The total number of variables in nVarsAll. The last argument (Phase) contains shows where the variables should go.]

SideEffects [The input truth table is modified.]

SeeAlso []

Definition at line 166 of file kitTruth.c.

167 {
168  unsigned * pTemp;
169  int i, k, Var = nVars - 1, Counter = 0;
170  for ( i = nVarsAll - 1; i >= 0; i-- )
171  if ( Phase & (1 << i) )
172  {
173  for ( k = Var; k < i; k++ )
174  {
175  Kit_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
176  pTemp = pIn; pIn = pOut; pOut = pTemp;
177  Counter++;
178  }
179  Var--;
180  }
181  assert( Var == -1 );
182  // swap if it was moved an even number of times
183  if ( fReturnIn ^ !(Counter & 1) )
184  Kit_TruthCopy( pOut, pIn, nVarsAll );
185 }
ABC_NAMESPACE_IMPL_START void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
DECLARATIONS ///.
Definition: kitTruth.c:46
static int Counter
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
int Var
Definition: SolverTypes.h:42
#define assert(ex)
Definition: util_old.h:213
unsigned Kit_TruthSupport ( unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Returns support of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 346 of file kitTruth.c.

347 {
348  int i, Support = 0;
349  for ( i = 0; i < nVars; i++ )
350  if ( Kit_TruthVarInSupport( pTruth, nVars, i ) )
351  Support |= (1 << i);
352  return Support;
353 }
int Kit_TruthVarInSupport(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:270
int Kit_TruthSupportSize ( unsigned *  pTruth,
int  nVars 
)

Function*************************************************************

Synopsis [Returns the number of support vars.]

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file kitTruth.c.

328 {
329  int i, Counter = 0;
330  for ( i = 0; i < nVars; i++ )
331  Counter += Kit_TruthVarInSupport( pTruth, nVars, i );
332  return Counter;
333 }
int Kit_TruthVarInSupport(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:270
static int Counter
void Kit_TruthSwapAdjacentVars ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
int  iVar 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [kitTruth.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Procedures involving truth tables.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitTruth.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Swaps two adjacent variables in the truth table.]

Description [Swaps var number Start and var number Start+1 (0-based numbers). The input truth table is pIn. The output truth table is pOut.]

SideEffects []

SeeAlso []

Definition at line 46 of file kitTruth.c.

47 {
48  static unsigned PMasks[4][3] = {
49  { 0x99999999, 0x22222222, 0x44444444 },
50  { 0xC3C3C3C3, 0x0C0C0C0C, 0x30303030 },
51  { 0xF00FF00F, 0x00F000F0, 0x0F000F00 },
52  { 0xFF0000FF, 0x0000FF00, 0x00FF0000 }
53  };
54  int nWords = Kit_TruthWordNum( nVars );
55  int i, k, Step, Shift;
56 
57  assert( iVar < nVars - 1 );
58  if ( iVar < 4 )
59  {
60  Shift = (1 << iVar);
61  for ( i = 0; i < nWords; i++ )
62  pOut[i] = (pIn[i] & PMasks[iVar][0]) | ((pIn[i] & PMasks[iVar][1]) << Shift) | ((pIn[i] & PMasks[iVar][2]) >> Shift);
63  }
64  else if ( iVar > 4 )
65  {
66  Step = (1 << (iVar - 5));
67  for ( k = 0; k < nWords; k += 4*Step )
68  {
69  for ( i = 0; i < Step; i++ )
70  pOut[i] = pIn[i];
71  for ( i = 0; i < Step; i++ )
72  pOut[Step+i] = pIn[2*Step+i];
73  for ( i = 0; i < Step; i++ )
74  pOut[2*Step+i] = pIn[Step+i];
75  for ( i = 0; i < Step; i++ )
76  pOut[3*Step+i] = pIn[3*Step+i];
77  pIn += 4*Step;
78  pOut += 4*Step;
79  }
80  }
81  else // if ( iVar == 4 )
82  {
83  for ( i = 0; i < nWords; i += 2 )
84  {
85  pOut[i] = (pIn[i] & 0x0000FFFF) | ((pIn[i+1] & 0x0000FFFF) << 16);
86  pOut[i+1] = (pIn[i+1] & 0xFFFF0000) | ((pIn[i] & 0xFFFF0000) >> 16);
87  }
88  }
89 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
static word PMasks[5][3]
Definition: ifDec07.c:44
#define assert(ex)
Definition: util_old.h:213
DdNode* Kit_TruthToBdd ( DdManager dd,
unsigned *  pTruth,
int  nVars,
int  fMSBonTop 
)

Function*************************************************************

Synopsis [Compute BDD corresponding to the truth table.]

Description [If truth table has N vars, the BDD depends on N topmost variables of the BDD manager. The most significant variable of the table is encoded by the topmost variable of the manager. BDD construction is efficient in this case because BDD is constructed one node at a time, by simply adding BDD nodes on top of existent BDD nodes.]

SideEffects []

SeeAlso []

Definition at line 182 of file kitBdd.c.

183 {
184  return Kit_TruthToBdd_rec( dd, pTruth, 0, nVars, nVars, fMSBonTop );
185 }
DdNode * Kit_TruthToBdd_rec(DdManager *dd, unsigned *pTruth, int iBit, int nVars, int nVarsTotal, int fMSBonTop)
Definition: kitBdd.c:141
CloudNode* Kit_TruthToCloud ( CloudManager dd,
unsigned *  pTruth,
int  nVars 
)

Function********************************************************************

Synopsis [Compute BDD for the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 148 of file kitCloud.c.

149 {
150  CloudNode * pRes;
151  pRes = Kit_TruthToCloud_rec( dd, pTruth, nVars, nVars );
152 // printf( "%d/%d ", Count, Cloud_DagSize(dd, pRes) );
153  return pRes;
154 }
CloudNode * Kit_TruthToCloud_rec(CloudManager *dd, unsigned *pTruth, int nVars, int nVarsAll)
Definition: kitCloud.c:109
Kit_Graph_t* Kit_TruthToGraph ( unsigned *  pTruth,
int  nVars,
Vec_Int_t vMemory 
)

Function*************************************************************

Synopsis [Derives the factored form from the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 355 of file kitGraph.c.

356 {
357  Kit_Graph_t * pGraph;
358  int RetValue;
359  // derive SOP
360  RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 1 ); // tried 1 and found not useful in "renode"
361  if ( RetValue == -1 )
362  return NULL;
363  if ( Vec_IntSize(vMemory) > (1<<16) )
364  return NULL;
365 // printf( "Isop size = %d.\n", Vec_IntSize(vMemory) );
366  assert( RetValue == 0 || RetValue == 1 );
367  // derive factored form
368  pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory );
369  return pGraph;
370 }
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
Kit_Graph_t * Kit_SopFactor(Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
FUNCTION DEFINITIONS ///.
Definition: kitFactor.c:55
void Kit_TruthUniqueNew ( unsigned *  pRes,
unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Universally quantifies the variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 922 of file kitTruth.c.

923 {
924  int nWords = Kit_TruthWordNum( nVars );
925  int i, k, Step;
926 
927  assert( iVar < nVars );
928  switch ( iVar )
929  {
930  case 0:
931  for ( i = 0; i < nWords; i++ )
932  pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1));
933  return;
934  case 1:
935  for ( i = 0; i < nWords; i++ )
936  pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2));
937  return;
938  case 2:
939  for ( i = 0; i < nWords; i++ )
940  pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4));
941  return;
942  case 3:
943  for ( i = 0; i < nWords; i++ )
944  pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8));
945  return;
946  case 4:
947  for ( i = 0; i < nWords; i++ )
948  pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16));
949  return;
950  default:
951  Step = (1 << (iVar - 5));
952  for ( k = 0; k < nWords; k += 2*Step )
953  {
954  for ( i = 0; i < Step; i++ )
955  {
956  pRes[i] = pTruth[i] ^ pTruth[Step+i];
957  pRes[Step+i] = pRes[i];
958  }
959  pRes += 2*Step;
960  pTruth += 2*Step;
961  }
962  return;
963  }
964 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
int Kit_TruthVarInSupport ( unsigned *  pTruth,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Returns 1 if TT depends on the given variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file kitTruth.c.

271 {
272  int nWords = Kit_TruthWordNum( nVars );
273  int i, k, Step;
274 
275  assert( iVar < nVars );
276  switch ( iVar )
277  {
278  case 0:
279  for ( i = 0; i < nWords; i++ )
280  if ( (pTruth[i] & 0x55555555) != ((pTruth[i] & 0xAAAAAAAA) >> 1) )
281  return 1;
282  return 0;
283  case 1:
284  for ( i = 0; i < nWords; i++ )
285  if ( (pTruth[i] & 0x33333333) != ((pTruth[i] & 0xCCCCCCCC) >> 2) )
286  return 1;
287  return 0;
288  case 2:
289  for ( i = 0; i < nWords; i++ )
290  if ( (pTruth[i] & 0x0F0F0F0F) != ((pTruth[i] & 0xF0F0F0F0) >> 4) )
291  return 1;
292  return 0;
293  case 3:
294  for ( i = 0; i < nWords; i++ )
295  if ( (pTruth[i] & 0x00FF00FF) != ((pTruth[i] & 0xFF00FF00) >> 8) )
296  return 1;
297  return 0;
298  case 4:
299  for ( i = 0; i < nWords; i++ )
300  if ( (pTruth[i] & 0x0000FFFF) != ((pTruth[i] & 0xFFFF0000) >> 16) )
301  return 1;
302  return 0;
303  default:
304  Step = (1 << (iVar - 5));
305  for ( k = 0; k < nWords; k += 2*Step )
306  {
307  for ( i = 0; i < Step; i++ )
308  if ( pTruth[i] != pTruth[Step+i] )
309  return 1;
310  pTruth += 2*Step;
311  }
312  return 0;
313  }
314 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
int Kit_TruthVarIsVacuous ( unsigned *  pOnset,
unsigned *  pOffset,
int  nVars,
int  iVar 
)

Function*************************************************************

Synopsis [Computes negative cofactor of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 625 of file kitTruth.c.

626 {
627  int nWords = Kit_TruthWordNum( nVars );
628  int i, k, Step;
629 
630  assert( iVar < nVars );
631  switch ( iVar )
632  {
633  case 0:
634  for ( i = 0; i < nWords; i++ )
635  if ( ((pOnset[i] & (pOffset[i] >> 1)) | (pOffset[i] & (pOnset[i] >> 1))) & 0x55555555 )
636  return 0;
637  return 1;
638  case 1:
639  for ( i = 0; i < nWords; i++ )
640  if ( ((pOnset[i] & (pOffset[i] >> 2)) | (pOffset[i] & (pOnset[i] >> 2))) & 0x33333333 )
641  return 0;
642  return 1;
643  case 2:
644  for ( i = 0; i < nWords; i++ )
645  if ( ((pOnset[i] & (pOffset[i] >> 4)) | (pOffset[i] & (pOnset[i] >> 4))) & 0x0F0F0F0F )
646  return 0;
647  return 1;
648  case 3:
649  for ( i = 0; i < nWords; i++ )
650  if ( ((pOnset[i] & (pOffset[i] >> 8)) | (pOffset[i] & (pOnset[i] >> 8))) & 0x00FF00FF )
651  return 0;
652  return 1;
653  case 4:
654  for ( i = 0; i < nWords; i++ )
655  if ( ((pOnset[i] & (pOffset[i] >> 16)) | (pOffset[i] & (pOnset[i] >> 16))) & 0x0000FFFF )
656  return 0;
657  return 1;
658  default:
659  Step = (1 << (iVar - 5));
660  for ( k = 0; k < nWords; k += 2*Step )
661  {
662  for ( i = 0; i < Step; i++ )
663  if ( (pOnset[i] & pOffset[Step+i]) | (pOffset[i] & pOnset[Step+i]) )
664  return 0;
665  pOnset += 2*Step;
666  pOffset += 2*Step;
667  }
668  return 1;
669  }
670 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
int Kit_TruthVarsAntiSymm ( unsigned *  pTruth,
int  nVars,
int  iVar0,
int  iVar1,
unsigned *  pCof0,
unsigned *  pCof1 
)

Function*************************************************************

Synopsis [Checks antisymmetry of two variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 1223 of file kitTruth.c.

1224 {
1225  static unsigned uTemp0[32], uTemp1[32];
1226  if ( pCof0 == NULL )
1227  {
1228  assert( nVars <= 10 );
1229  pCof0 = uTemp0;
1230  }
1231  if ( pCof1 == NULL )
1232  {
1233  assert( nVars <= 10 );
1234  pCof1 = uTemp1;
1235  }
1236  // compute Cof00
1237  Kit_TruthCopy( pCof0, pTruth, nVars );
1238  Kit_TruthCofactor0( pCof0, nVars, iVar0 );
1239  Kit_TruthCofactor0( pCof0, nVars, iVar1 );
1240  // compute Cof11
1241  Kit_TruthCopy( pCof1, pTruth, nVars );
1242  Kit_TruthCofactor1( pCof1, nVars, iVar0 );
1243  Kit_TruthCofactor1( pCof1, nVars, iVar1 );
1244  // compare
1245  return Kit_TruthIsEqual( pCof0, pCof1, nVars );
1246 }
void Kit_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:470
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
void Kit_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:368
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
#define assert(ex)
Definition: util_old.h:213
int Kit_TruthVarsSymm ( unsigned *  pTruth,
int  nVars,
int  iVar0,
int  iVar1,
unsigned *  pCof0,
unsigned *  pCof1 
)

Function*************************************************************

Synopsis [Checks symmetry of two variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 1187 of file kitTruth.c.

1188 {
1189  static unsigned uTemp0[32], uTemp1[32];
1190  if ( pCof0 == NULL )
1191  {
1192  assert( nVars <= 10 );
1193  pCof0 = uTemp0;
1194  }
1195  if ( pCof1 == NULL )
1196  {
1197  assert( nVars <= 10 );
1198  pCof1 = uTemp1;
1199  }
1200  // compute Cof01
1201  Kit_TruthCopy( pCof0, pTruth, nVars );
1202  Kit_TruthCofactor0( pCof0, nVars, iVar0 );
1203  Kit_TruthCofactor1( pCof0, nVars, iVar1 );
1204  // compute Cof10
1205  Kit_TruthCopy( pCof1, pTruth, nVars );
1206  Kit_TruthCofactor1( pCof1, nVars, iVar0 );
1207  Kit_TruthCofactor0( pCof1, nVars, iVar1 );
1208  // compare
1209  return Kit_TruthIsEqual( pCof0, pCof1, nVars );
1210 }
void Kit_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:470
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
void Kit_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:368
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
#define assert(ex)
Definition: util_old.h:213
static int Kit_TruthWordNum ( int  nVars)
inlinestatic

Definition at line 224 of file kit.h.

224 { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static void Kit_TruthXor ( unsigned *  pOut,
unsigned *  pIn0,
unsigned *  pIn1,
int  nVars 
)
inlinestatic

Definition at line 391 of file kit.h.

392 {
393  int w;
394  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
395  pOut[w] = pIn0[w] ^ pIn1[w];
396 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Kit_TruthXorBit ( unsigned *  p,
int  Bit 
)
inlinestatic

Definition at line 228 of file kit.h.

228 { p[Bit>>5] ^= (1<<(Bit & 31)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Kit_WordCountOnes ( unsigned  uWord)
inlinestatic

Definition at line 243 of file kit.h.

244 {
245  uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
246  uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
247  uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
248  uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
249  return (uWord & 0x0000FFFF) + (uWord>>16);
250 }
static int Kit_WordFindFirstBit ( unsigned  uWord)
inlinestatic

Definition at line 231 of file kit.h.

232 {
233  int i;
234  for ( i = 0; i < 32; i++ )
235  if ( uWord & (1 << i) )
236  return i;
237  return -1;
238 }
static int Kit_WordHasOneBit ( unsigned  uWord)
inlinestatic

Definition at line 239 of file kit.h.

240 {
241  return (uWord & (uWord - 1)) == 0;
242 }