ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
kit.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "cloud.h"
Include dependency graph for kit.h:

Go to the source code of this file.

Classes

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)
 
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
 
#define Kit_DsdObjForEachFaninReverse(pNtk, pObj, iLit, i)
 
#define Kit_PlaForEachCube(pSop, nFanins, pCube)
 
#define Kit_PlaCubeForEachVar(pCube, Value, i)
 
#define KIT_MIN(a, b)
 MACRO DEFINITIONS ///.
 
#define KIT_MAX(a, b)
 
#define KIT_INFINITY   (100000000)
 
#define Kit_SopForEachCube(cSop, uCube, i)
 ITERATORS ///.
 
#define Kit_CubeForEachLiteral(uCube, Lit, nLits, i)
 
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)
 
#define Kit_GraphForEachNode(pGraph, pAnd, i)
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
 INCLUDES ///.
 
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

CloudNodeKit_TruthToCloud (CloudManager *dd, unsigned *pTruth, int nVars)
 FUNCTION DECLARATIONS ///.
 
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 ///.
 
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 ///.
 
Kit_Graph_tKit_GraphCreate (int nLeaves)
 DECLARATIONS ///.
 
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)
 
Kit_Graph_tKit_TruthToGraph2 (unsigned *pTruth0, unsigned *pTruth1, int nVars, Vec_Int_t *vMemory)
 
int Kit_GraphLeafDepth_rec (Kit_Graph_t *pGraph, Kit_Node_t *pNode, Kit_Node_t *pLeaf)
 
int Kit_TruthLitNum (unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
 
int Kit_IsopNodeNum (unsigned *pTruth0, unsigned *pTruth1, int nVars, Vec_Int_t *vMemory)
 
Vec_Int_tKit_IsopResub (unsigned *pTruth0, unsigned *pTruth1, int nVars, Vec_Int_t *vMemory)
 
int Kit_TruthIsop (unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
 
int Kit_TruthIsop2 (unsigned *puTruth0, unsigned *puTruth1, int nVars, Vec_Int_t *vMemory, int fTryBoth, int fReturnTt)
 FUNCTION DEFINITIONS ///.
 
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 ///.
 
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 ///.
 
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 ///.
 
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

◆ Kit_CubeForEachLiteral

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

Definition at line 502 of file kit.h.

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

◆ Kit_DsdNtkForEachObj

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

Definition at line 158 of file kit.h.

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

◆ Kit_DsdObjForEachFanin

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

Definition at line 160 of file kit.h.

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

◆ Kit_DsdObjForEachFaninReverse

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

Definition at line 162 of file kit.h.

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

◆ Kit_GraphForEachLeaf

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

Definition at line 505 of file kit.h.

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

◆ Kit_GraphForEachNode

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

Definition at line 507 of file kit.h.

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

◆ KIT_INFINITY

#define KIT_INFINITY   (100000000)

Definition at line 176 of file kit.h.

◆ KIT_MAX

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

Definition at line 175 of file kit.h.

◆ KIT_MIN

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

MACRO DEFINITIONS ///.

Definition at line 174 of file kit.h.

◆ Kit_PlaCubeForEachVar

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

Definition at line 167 of file kit.h.

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

◆ Kit_PlaForEachCube

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

Definition at line 165 of file kit.h.

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

◆ Kit_SopForEachCube

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

ITERATORS ///.

Definition at line 500 of file kit.h.

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

Typedef Documentation

◆ Kit_DsdMan_t

typedef struct Kit_DsdMan_t_ Kit_DsdMan_t

Definition at line 137 of file kit.h.

◆ Kit_DsdNtk_t

typedef struct Kit_DsdNtk_t_ Kit_DsdNtk_t

Definition at line 124 of file kit.h.

◆ Kit_DsdObj_t

typedef struct Kit_DsdObj_t_ Kit_DsdObj_t

Definition at line 111 of file kit.h.

◆ Kit_Edge_t

typedef struct Kit_Edge_t_ Kit_Edge_t

Definition at line 62 of file kit.h.

◆ Kit_Graph_t

typedef struct Kit_Graph_t_ Kit_Graph_t

Definition at line 88 of file kit.h.

◆ Kit_Node_t

typedef struct Kit_Node_t_ Kit_Node_t

Definition at line 69 of file kit.h.

◆ Kit_Sop_t

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 54 of file kit.h.

Enumeration Type Documentation

◆ Kit_Dsd_t

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 101 of file kit.h.

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

Function Documentation

◆ Kit_CloudToTruth()

unsigned * Kit_CloudToTruth ( Vec_Int_t * vNodes,
int nVars,
Vec_Ptr_t * vStore,
int fInv )
extern

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}
typedefABC_NAMESPACE_IMPL_START struct Kit_Mux_t_ Kit_Mux_t
DECLARATIONS ///.
Definition kitCloud.c:31
void Kit_TruthMuxVarPhase(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar, int fCompl0)
Definition kitTruth.c:1125
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
Here is the call graph for this function:

◆ Kit_CreateCloud()

int Kit_CreateCloud ( CloudManager * dd,
CloudNode * pFunc,
Vec_Int_t * vNodes )
extern

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}
int Cloud_DagCollect(CloudManager *dd, CloudNode *n)
Definition cloud.c:772
int Cloud_DagSize(CloudManager *dd, CloudNode *n)
Definition cloud.c:721
#define Cloud_Regular(p)
Definition cloud.h:185
#define Cloud_IsComplement(p)
Definition cloud.h:188
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_CreateCloudFromTruth()

int Kit_CreateCloudFromTruth ( CloudManager * dd,
unsigned * pTruth,
int nVars,
Vec_Int_t * vNodes )
extern

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}
void Cloud_Restart(CloudManager *dd)
Definition cloud.c:166
struct cloudNode CloudNode
Definition cloud.h:55
int Kit_CreateCloud(CloudManager *dd, CloudNode *pFunc, Vec_Int_t *vNodes)
Definition kitCloud.c:167
CloudNode * Kit_TruthToCloud(CloudManager *dd, unsigned *pTruth, int nVars)
FUNCTION DECLARATIONS ///.
Definition kitCloud.c:148
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdCofactoring()

int Kit_DsdCofactoring ( unsigned * pTruth,
int nVars,
int * pCofVars,
int nLimit,
int fVerbose )
extern

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 2679 of file kitDsd.c.

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

◆ Kit_DsdCountAigNodes()

int Kit_DsdCountAigNodes ( Kit_DsdNtk_t * pNtk)
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1896 of file kitDsd.c.

1897{
1898 Kit_DsdObj_t * pObj;
1899 int i, Counter = 0;
1900 for ( i = 0; i < pNtk->nNodes; i++ )
1901 {
1902 pObj = pNtk->pNodes[i];
1903 if ( pObj->Type == KIT_DSD_AND )
1904 Counter += ((int)pObj->nFans - 1);
1905 else if ( pObj->Type == KIT_DSD_XOR )
1906 Counter += ((int)pObj->nFans - 1) * 3;
1907 else if ( pObj->Type == KIT_DSD_PRIME ) // assuming MUX decomposition
1908 Counter += 3;
1909 }
1910 return Counter;
1911}
struct Kit_DsdObj_t_ Kit_DsdObj_t
Definition kit.h:111
Kit_DsdObj_t ** pNodes
Definition kit.h:133
unsigned short nNodes
Definition kit.h:129
unsigned Type
Definition kit.h:115
unsigned nFans
Definition kit.h:119
Here is the caller graph for this function:

◆ Kit_DsdDecompose()

Kit_DsdNtk_t * Kit_DsdDecompose ( unsigned * pTruth,
int nVars )
extern

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

Synopsis [Performs decomposition of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 2315 of file kitDsd.c.

2316{
2317 return Kit_DsdDecomposeInt( pTruth, nVars, 0 );
2318}
Kit_DsdNtk_t * Kit_DsdDecomposeInt(unsigned *pTruth, int nVars, int nDecMux)
Definition kitDsd.c:2267
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdDecomposeExpand()

Kit_DsdNtk_t * Kit_DsdDecomposeExpand ( unsigned * pTruth,
int nVars )
extern

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

Synopsis [Performs decomposition of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 2331 of file kitDsd.c.

2332{
2333 Kit_DsdNtk_t * pNtk, * pTemp;
2334 pNtk = Kit_DsdDecomposeInt( pTruth, nVars, 0 );
2335 pNtk = Kit_DsdExpand( pTemp = pNtk );
2336 Kit_DsdNtkFree( pTemp );
2337 return pNtk;
2338}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdDecomposeMux()

Kit_DsdNtk_t * Kit_DsdDecomposeMux ( unsigned * pTruth,
int nVars,
int nDecMux )
extern

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

Synopsis [Performs decomposition of the truth table.]

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

SideEffects []

SeeAlso []

Definition at line 2351 of file kitDsd.c.

2352{
2353/*
2354 Kit_DsdNtk_t * pNew;
2355 Kit_DsdObj_t * pObjNew;
2356 assert( nVars <= 16 );
2357 // create a new network
2358 pNew = Kit_DsdNtkAlloc( nVars );
2359 // consider simple special cases
2360 if ( nVars == 0 )
2361 {
2362 pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
2363 pNew->Root = Abc_Var2Lit( pObjNew->Id, (int)(pTruth[0] == 0) );
2364 return pNew;
2365 }
2366 if ( nVars == 1 )
2367 {
2368 pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
2369 pObjNew->pFans[0] = Abc_Var2Lit( 0, 0 );
2370 pNew->Root = Abc_Var2Lit( pObjNew->Id, (int)(pTruth[0] != 0xAAAAAAAA) );
2371 return pNew;
2372 }
2373*/
2374 return Kit_DsdDecomposeInt( pTruth, nVars, nDecMux );
2375}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdDeriveNtk()

Kit_DsdNtk_t * Kit_DsdDeriveNtk ( unsigned * pTruth,
int nVars,
int nLutSize )
extern

◆ Kit_DsdExpand()

Kit_DsdNtk_t * Kit_DsdExpand ( Kit_DsdNtk_t * p)
extern

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

Synopsis [Expands the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 1452 of file kitDsd.c.

1453{
1454 Kit_DsdNtk_t * pNew;
1455 Kit_DsdObj_t * pObjNew;
1456 assert( p->nVars <= 16 );
1457 // create a new network
1458 pNew = Kit_DsdNtkAlloc( p->nVars );
1459 // consider simple special cases
1460 if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_CONST1 )
1461 {
1462 pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
1463 pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1464 return pNew;
1465 }
1466 if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_VAR )
1467 {
1468 pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
1469 pObjNew->pFans[0] = Kit_DsdNtkRoot(p)->pFans[0];
1470 pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1471 return pNew;
1472 }
1473 // convert the root node
1474 pNew->Root = Kit_DsdExpandNode_rec( pNew, p, p->Root );
1475 return pNew;
1476}
Cube * p
Definition exorList.c:222
Kit_DsdObj_t * Kit_DsdObjAlloc(Kit_DsdNtk_t *pNtk, Kit_Dsd_t Type, int nFans)
Definition kitDsd.c:93
Kit_DsdNtk_t * Kit_DsdNtkAlloc(int nVars)
Definition kitDsd.c:141
int Kit_DsdExpandNode_rec(Kit_DsdNtk_t *pNew, Kit_DsdNtk_t *p, int iLit)
Definition kitDsd.c:1350
unsigned short Root
Definition kit.h:130
unsigned short pFans[0]
Definition kit.h:120
unsigned Id
Definition kit.h:114
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdGetSupports()

unsigned Kit_DsdGetSupports ( Kit_DsdNtk_t * p)
extern

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

Synopsis [Compute the support.]

Description []

SideEffects []

SeeAlso []

Definition at line 1763 of file kitDsd.c.

1764{
1765 Kit_DsdObj_t * pRoot;
1766 unsigned uSupport;
1767 assert( p->pSupps == NULL );
1768 p->pSupps = ABC_ALLOC( unsigned, p->nNodes );
1769 // consider simple special cases
1770 pRoot = Kit_DsdNtkRoot(p);
1771 if ( pRoot->Type == KIT_DSD_CONST1 )
1772 {
1773 assert( p->nNodes == 1 );
1774 uSupport = p->pSupps[0] = 0;
1775 }
1776 if ( pRoot->Type == KIT_DSD_VAR )
1777 {
1778 assert( p->nNodes == 1 );
1779 uSupport = p->pSupps[0] = Kit_DsdLitSupport( p, pRoot->pFans[0] );
1780 }
1781 else
1782 uSupport = Kit_DsdGetSupports_rec( p, p->Root );
1783 assert( uSupport <= 0xFFFF );
1784 return uSupport;
1785}
unsigned Kit_DsdGetSupports_rec(Kit_DsdNtk_t *p, int iLit)
Definition kitDsd.c:1736
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdManAlloc()

Kit_DsdMan_t * Kit_DsdManAlloc ( int nVars,
int nNodes )
extern

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 46 of file kitDsd.c.

47{
49 p = ABC_ALLOC( Kit_DsdMan_t, 1 );
50 memset( p, 0, sizeof(Kit_DsdMan_t) );
51 p->nVars = nVars;
52 p->nWords = Kit_TruthWordNum( p->nVars );
53 p->vTtElems = Vec_PtrAllocTruthTables( p->nVars );
54 p->vTtNodes = Vec_PtrAllocSimInfo( nNodes, p->nWords );
55 p->dd = Cloud_Init( 16, 14 );
56 p->vTtBdds = Vec_PtrAllocSimInfo( (1<<12), p->nWords );
57 p->vNodes = Vec_IntAlloc( 512 );
58 return p;
59}
CloudManager * Cloud_Init(int nVars, int nBits)
FUNCTION DEFINITIONS ///.
Definition cloud.c:70
struct Kit_DsdMan_t_ Kit_DsdMan_t
Definition kit.h:137
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdManFree()

void Kit_DsdManFree ( Kit_DsdMan_t * p)
extern

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

Synopsis [Deallocates the DSD manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file kitDsd.c.

73{
74 Cloud_Quit( p->dd );
75 Vec_IntFree( p->vNodes );
76 Vec_PtrFree( p->vTtBdds );
77 Vec_PtrFree( p->vTtElems );
78 Vec_PtrFree( p->vTtNodes );
79 ABC_FREE( p );
80}
void Cloud_Quit(CloudManager *dd)
Definition cloud.c:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdNonDsdPrimeMax()

Kit_DsdObj_t * Kit_DsdNonDsdPrimeMax ( Kit_DsdNtk_t * pNtk)
extern

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

Synopsis [Returns the largest non-DSD block.]

Description []

SideEffects []

SeeAlso []

Definition at line 1237 of file kitDsd.c.

1238{
1239 Kit_DsdObj_t * pObj, * pObjMax = NULL;
1240 unsigned i, nSizeMax = 0;
1241 Kit_DsdNtkForEachObj( pNtk, pObj, i )
1242 {
1243 if ( pObj->Type != KIT_DSD_PRIME )
1244 continue;
1245 if ( nSizeMax < pObj->nFans )
1246 {
1247 nSizeMax = pObj->nFans;
1248 pObjMax = pObj;
1249 }
1250 }
1251 return pObjMax;
1252}
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
Definition kit.h:158
Here is the caller graph for this function:

◆ Kit_DsdNonDsdSizeMax()

int Kit_DsdNonDsdSizeMax ( Kit_DsdNtk_t * pNtk)
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1212 of file kitDsd.c.

1213{
1214 Kit_DsdObj_t * pObj;
1215 unsigned i, nSizeMax = 0;
1216 Kit_DsdNtkForEachObj( pNtk, pObj, i )
1217 {
1218 if ( pObj->Type != KIT_DSD_PRIME )
1219 continue;
1220 if ( nSizeMax < pObj->nFans )
1221 nSizeMax = pObj->nFans;
1222 }
1223 return nSizeMax;
1224}
Here is the caller graph for this function:

◆ Kit_DsdNonDsdSupports()

unsigned Kit_DsdNonDsdSupports ( Kit_DsdNtk_t * pNtk)
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1265 of file kitDsd.c.

1266{
1267 Kit_DsdObj_t * pObj;
1268 unsigned i, uSupport = 0;
1269// ABC_FREE( pNtk->pSupps );
1270 Kit_DsdGetSupports( pNtk );
1271 Kit_DsdNtkForEachObj( pNtk, pObj, i )
1272 {
1273 if ( pObj->Type != KIT_DSD_PRIME )
1274 continue;
1275 uSupport |= Kit_DsdLitSupport( pNtk, Abc_Var2Lit(pObj->Id,0) );
1276 }
1277 return uSupport;
1278}
unsigned Kit_DsdGetSupports(Kit_DsdNtk_t *p)
Definition kitDsd.c:1763
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdNtkFree()

void Kit_DsdNtkFree ( Kit_DsdNtk_t * pNtk)
extern

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

Synopsis [Deallocate the DSD network.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file kitDsd.c.

165{
166 Kit_DsdObj_t * pObj;
167 unsigned i;
168 Kit_DsdNtkForEachObj( pNtk, pObj, i )
169 ABC_FREE( pObj );
170 ABC_FREE( pNtk->pSupps );
171 ABC_FREE( pNtk->pNodes );
172 ABC_FREE( pNtk->pMem );
173 ABC_FREE( pNtk );
174}
unsigned * pSupps
Definition kit.h:132
unsigned * pMem
Definition kit.h:131
Here is the caller graph for this function:

◆ Kit_DsdPrint()

void Kit_DsdPrint ( FILE * pFile,
Kit_DsdNtk_t * pNtk )
extern

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 375 of file kitDsd.c.

376{
377 fprintf( pFile, "F = " );
378 if ( Abc_LitIsCompl(pNtk->Root) )
379 fprintf( pFile, "!" );
380 Kit_DsdPrint_rec( pFile, pNtk, Abc_Lit2Var(pNtk->Root) );
381// fprintf( pFile, "\n" );
382}
void Kit_DsdPrint_rec(FILE *pFile, Kit_DsdNtk_t *pNtk, int Id)
Definition kitDsd.c:318
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdPrintExpanded()

void Kit_DsdPrintExpanded ( Kit_DsdNtk_t * pNtk)
extern

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 472 of file kitDsd.c.

473{
474 Kit_DsdNtk_t * pTemp;
475 pTemp = Kit_DsdExpand( pNtk );
476 Kit_DsdPrint( stdout, pTemp );
477 Kit_DsdNtkFree( pTemp );
478}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdPrintFromTruth()

void Kit_DsdPrintFromTruth ( unsigned * pTruth,
int nVars )
extern

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 491 of file kitDsd.c.

492{
493 Kit_DsdNtk_t * pTemp, * pTemp2;
494// pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
495 pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
496// Kit_DsdPrintExpanded( pTemp );
497 pTemp2 = Kit_DsdExpand( pTemp );
498 Kit_DsdPrint( stdout, pTemp2 );
499 Kit_DsdVerify( pTemp2, pTruth, nVars );
500 Kit_DsdNtkFree( pTemp2 );
501 Kit_DsdNtkFree( pTemp );
502}
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition kitDsd.c:2493
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition kitDsd.c:2351
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdPrintFromTruth2()

void Kit_DsdPrintFromTruth2 ( FILE * pFile,
unsigned * pTruth,
int nVars )
extern

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 515 of file kitDsd.c.

516{
517 Kit_DsdNtk_t * pTemp, * pTemp2;
518 pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 0 );
519 pTemp2 = Kit_DsdExpand( pTemp );
520 Kit_DsdPrint2( pFile, pTemp2 );
521 Kit_DsdVerify( pTemp2, pTruth, nVars );
522 Kit_DsdNtkFree( pTemp2 );
523 Kit_DsdNtkFree( pTemp );
524}
void Kit_DsdPrint2(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition kitDsd.c:298
Here is the call graph for this function:

◆ Kit_DsdRotate()

void Kit_DsdRotate ( Kit_DsdNtk_t * p,
int pFreqs[] )
extern

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 1672 of file kitDsd.c.

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

◆ Kit_DsdShrink()

Kit_DsdNtk_t * Kit_DsdShrink ( Kit_DsdNtk_t * p,
int pPrios[] )
extern

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 1634 of file kitDsd.c.

1635{
1636 Kit_DsdNtk_t * pNew;
1637 Kit_DsdObj_t * pObjNew;
1638 assert( p->nVars <= 16 );
1639 // create a new network
1640 pNew = Kit_DsdNtkAlloc( p->nVars );
1641 // consider simple special cases
1642 if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_CONST1 )
1643 {
1644 pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
1645 pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1646 return pNew;
1647 }
1648 if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_VAR )
1649 {
1650 pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
1651 pObjNew->pFans[0] = Kit_DsdNtkRoot(p)->pFans[0];
1652 pNew->Root = Abc_Var2Lit( pObjNew->Id, Abc_LitIsCompl(p->Root) );
1653 return pNew;
1654 }
1655 // convert the root node
1656 pNew->Root = Kit_DsdShrink_rec( pNew, p, p->Root, pPrios );
1657 return pNew;
1658}
int Kit_DsdShrink_rec(Kit_DsdNtk_t *pNew, Kit_DsdNtk_t *p, int iLit, int pPrios[])
Definition kitDsd.c:1544
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdTruth()

void Kit_DsdTruth ( Kit_DsdNtk_t * pNtk,
unsigned * pTruthRes )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1069 of file kitDsd.c.

1070{
1071 Kit_DsdMan_t * p;
1072 unsigned * pTruth;
1073 p = Kit_DsdManAlloc( pNtk->nVars, Kit_DsdNtkObjNum(pNtk) );
1074 pTruth = Kit_DsdTruthCompute( p, pNtk );
1075 Kit_TruthCopy( pTruthRes, pTruth, pNtk->nVars );
1076 Kit_DsdManFree( p );
1077}
ABC_NAMESPACE_IMPL_START Kit_DsdMan_t * Kit_DsdManAlloc(int nVars, int nNodes)
DECLARATIONS ///.
Definition kitDsd.c:46
void Kit_DsdManFree(Kit_DsdMan_t *p)
Definition kitDsd.c:72
unsigned * Kit_DsdTruthCompute(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk)
Definition kitDsd.c:664
unsigned short nVars
Definition kit.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdTruthCompute()

unsigned * Kit_DsdTruthCompute ( Kit_DsdMan_t * p,
Kit_DsdNtk_t * pNtk )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 664 of file kitDsd.c.

665{
666 unsigned * pTruthRes;
667 int i;
668 // assign elementary truth ables
669 assert( pNtk->nVars <= p->nVars );
670 for ( i = 0; i < (int)pNtk->nVars; i++ )
671 Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
672 // compute truth table for each node
673 pTruthRes = Kit_DsdTruthComputeNode_rec( p, pNtk, Abc_Lit2Var(pNtk->Root) );
674 // complement the truth table if needed
675 if ( Abc_LitIsCompl(pNtk->Root) )
676 Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
677 return pTruthRes;
678}
unsigned * Kit_DsdTruthComputeNode_rec(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, int Id)
Definition kitDsd.c:561
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdTruthPartial()

void Kit_DsdTruthPartial ( Kit_DsdMan_t * p,
Kit_DsdNtk_t * pNtk,
unsigned * pTruthRes,
unsigned uSupp )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1108 of file kitDsd.c.

1109{
1110 unsigned * pTruth = Kit_DsdTruthComputeOne( p, pNtk, uSupp );
1111 Kit_TruthCopy( pTruthRes, pTruth, pNtk->nVars );
1112/*
1113 // verification
1114 {
1115 // compute the same function using different procedure
1116 unsigned * pTruthTemp = Vec_PtrEntry(p->vTtNodes, pNtk->nVars + pNtk->nNodes + 1);
1117 pNtk->pSupps = NULL;
1118 Kit_DsdTruthComputeTwo( p, pNtk, uSupp, -1, pTruthTemp );
1119// if ( !Kit_TruthIsEqual( pTruthTemp, pTruthRes, pNtk->nVars ) )
1120 if ( !Kit_TruthIsEqualWithPhase( pTruthTemp, pTruthRes, pNtk->nVars ) )
1121 {
1122 printf( "Verification FAILED!\n" );
1123 Kit_DsdPrint( stdout, pNtk );
1124 Kit_DsdPrintFromTruth( pTruthRes, pNtk->nVars );
1125 Kit_DsdPrintFromTruth( pTruthTemp, pNtk->nVars );
1126 }
1127// else
1128// printf( "Verification successful.\n" );
1129 }
1130*/
1131}
unsigned * Kit_DsdTruthComputeOne(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp)
Definition kitDsd.c:824
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdTruthPartialTwo()

void Kit_DsdTruthPartialTwo ( Kit_DsdMan_t * p,
Kit_DsdNtk_t * pNtk,
unsigned uSupp,
int iVar,
unsigned * pTruthCo,
unsigned * pTruthDec )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1090 of file kitDsd.c.

1091{
1092 unsigned * pTruth = Kit_DsdTruthComputeTwo( p, pNtk, uSupp, iVar, pTruthDec );
1093 if ( pTruthCo )
1094 Kit_TruthCopy( pTruthCo, pTruth, pNtk->nVars );
1095}
unsigned * Kit_DsdTruthComputeTwo(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp, int iVar, unsigned *pTruthDec)
Definition kitDsd.c:1025
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdVerify()

void Kit_DsdVerify ( Kit_DsdNtk_t * pNtk,
unsigned * pTruth,
int nVars )
extern

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

Synopsis [Performs decomposition of the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 2493 of file kitDsd.c.

2494{
2495 Kit_DsdMan_t * p;
2496 unsigned * pTruthC;
2497 p = Kit_DsdManAlloc( nVars, Kit_DsdNtkObjNum(pNtk)+2 );
2498 pTruthC = Kit_DsdTruthCompute( p, pNtk );
2499 if ( !Extra_TruthIsEqual( pTruth, pTruthC, nVars ) )
2500 printf( "Verification failed for gate with %d inputs.\n", nVars );
2501 Kit_DsdManFree( p );
2502}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_DsdWriteFromTruth()

void Kit_DsdWriteFromTruth ( char * pBuffer,
unsigned * pTruth,
int nVars )
extern

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 537 of file kitDsd.c.

538{
539 Kit_DsdNtk_t * pTemp, * pTemp2;
540// pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
541 pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
542// Kit_DsdPrintExpanded( pTemp );
543 pTemp2 = Kit_DsdExpand( pTemp );
544 Kit_DsdWrite( pBuffer, pTemp2 );
545 Kit_DsdVerify( pTemp2, pTruth, nVars );
546 Kit_DsdNtkFree( pTemp2 );
547 Kit_DsdNtkFree( pTemp );
548}
void Kit_DsdWrite(char *pBuff, Kit_DsdNtk_t *pNtk)
Definition kitDsd.c:453
Here is the call graph for this function:

◆ Kit_GraphAddNodeAnd()

Kit_Edge_t Kit_GraphAddNodeAnd ( Kit_Graph_t * pGraph,
Kit_Edge_t eEdge0,
Kit_Edge_t eEdge1 )
extern

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

Synopsis [Creates an AND node.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file kitGraph.c.

174{
175 Kit_Node_t * pNode;
176 // get the new node
177 pNode = Kit_GraphAppendNode( pGraph );
178 // set the inputs and other info
179 pNode->eEdge0 = eEdge0;
180 pNode->eEdge1 = eEdge1;
181 pNode->fCompl0 = eEdge0.fCompl;
182 pNode->fCompl1 = eEdge1.fCompl;
183 return Kit_EdgeCreate( pGraph->nSize - 1, 0 );
184}
Kit_Node_t * Kit_GraphAppendNode(Kit_Graph_t *pGraph)
Definition kitGraph.c:149
struct Kit_Node_t_ Kit_Node_t
Definition kit.h:69
unsigned fCompl
Definition kit.h:65
int nSize
Definition kit.h:93
Kit_Edge_t eEdge0
Definition kit.h:72
Kit_Edge_t eEdge1
Definition kit.h:73
unsigned fCompl1
Definition kit.h:81
unsigned fCompl0
Definition kit.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphAddNodeMux()

Kit_Edge_t Kit_GraphAddNodeMux ( Kit_Graph_t * pGraph,
Kit_Edge_t eEdgeC,
Kit_Edge_t eEdgeT,
Kit_Edge_t eEdgeE,
int Type )
extern

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

Synopsis [Creates an XOR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file kitGraph.c.

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

◆ Kit_GraphAddNodeOr()

Kit_Edge_t Kit_GraphAddNodeOr ( Kit_Graph_t * pGraph,
Kit_Edge_t eEdge0,
Kit_Edge_t eEdge1 )
extern

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

Synopsis [Creates an OR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file kitGraph.c.

198{
199 Kit_Node_t * pNode;
200 // get the new node
201 pNode = Kit_GraphAppendNode( pGraph );
202 // set the inputs and other info
203 pNode->eEdge0 = eEdge0;
204 pNode->eEdge1 = eEdge1;
205 pNode->fCompl0 = eEdge0.fCompl;
206 pNode->fCompl1 = eEdge1.fCompl;
207 // make adjustments for the OR gate
208 pNode->fNodeOr = 1;
209 pNode->eEdge0.fCompl = !pNode->eEdge0.fCompl;
210 pNode->eEdge1.fCompl = !pNode->eEdge1.fCompl;
211 return Kit_EdgeCreate( pGraph->nSize - 1, 1 );
212}
unsigned fNodeOr
Definition kit.h:79
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphAddNodeXor()

Kit_Edge_t Kit_GraphAddNodeXor ( Kit_Graph_t * pGraph,
Kit_Edge_t eEdge0,
Kit_Edge_t eEdge1,
int Type )
extern

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

Synopsis [Creates an XOR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file kitGraph.c.

226{
227 Kit_Edge_t eNode0, eNode1, eNode;
228 if ( Type == 0 )
229 {
230 // derive the first AND
231 eEdge0.fCompl ^= 1;
232 eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
233 eEdge0.fCompl ^= 1;
234 // derive the second AND
235 eEdge1.fCompl ^= 1;
236 eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
237 // derive the final OR
238 eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
239 }
240 else
241 {
242 // derive the first AND
243 eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
244 // derive the second AND
245 eEdge0.fCompl ^= 1;
246 eEdge1.fCompl ^= 1;
247 eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
248 // derive the final OR
249 eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
250 eNode.fCompl ^= 1;
251 }
252 return eNode;
253}
Here is the call graph for this function:

◆ Kit_GraphAppendNode()

Kit_Node_t * Kit_GraphAppendNode ( Kit_Graph_t * pGraph)
extern

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

Synopsis [Appends a new node to the graph.]

Description [This procedure is meant for internal use.]

SideEffects []

SeeAlso []

Definition at line 149 of file kitGraph.c.

150{
151 Kit_Node_t * pNode;
152 if ( pGraph->nSize == pGraph->nCap )
153 {
154 pGraph->pNodes = ABC_REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
155 pGraph->nCap = 2 * pGraph->nCap;
156 }
157 pNode = pGraph->pNodes + pGraph->nSize++;
158 memset( pNode, 0, sizeof(Kit_Node_t) );
159 return pNode;
160}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
Kit_Node_t * pNodes
Definition kit.h:95
int nCap
Definition kit.h:94
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphCreate()

Kit_Graph_t * Kit_GraphCreate ( int nLeaves)
extern

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 46 of file kitGraph.c.

47{
48 Kit_Graph_t * pGraph;
49 pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
50 memset( pGraph, 0, sizeof(Kit_Graph_t) );
51 pGraph->nLeaves = nLeaves;
52 pGraph->nSize = nLeaves;
53 pGraph->nCap = 2 * nLeaves + 50;
54 pGraph->pNodes = ABC_ALLOC( Kit_Node_t, pGraph->nCap );
55 memset( pGraph->pNodes, 0, sizeof(Kit_Node_t) * pGraph->nSize );
56 return pGraph;
57}
struct Kit_Graph_t_ Kit_Graph_t
Definition kit.h:88
int nLeaves
Definition kit.h:92
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphCreateConst0()

Kit_Graph_t * Kit_GraphCreateConst0 ( )
extern

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

Synopsis [Creates constant 0 graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file kitGraph.c.

71{
72 Kit_Graph_t * pGraph;
73 pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
74 memset( pGraph, 0, sizeof(Kit_Graph_t) );
75 pGraph->fConst = 1;
76 pGraph->eRoot.fCompl = 1;
77 return pGraph;
78}
Kit_Edge_t eRoot
Definition kit.h:96
int fConst
Definition kit.h:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphCreateConst1()

Kit_Graph_t * Kit_GraphCreateConst1 ( )
extern

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

Synopsis [Creates constant 1 graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file kitGraph.c.

92{
93 Kit_Graph_t * pGraph;
94 pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
95 memset( pGraph, 0, sizeof(Kit_Graph_t) );
96 pGraph->fConst = 1;
97 return pGraph;
98}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphCreateLeaf()

Kit_Graph_t * Kit_GraphCreateLeaf ( int iLeaf,
int nLeaves,
int fCompl )
extern

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

Synopsis [Creates the literal graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file kitGraph.c.

112{
113 Kit_Graph_t * pGraph;
114 assert( 0 <= iLeaf && iLeaf < nLeaves );
115 pGraph = Kit_GraphCreate( nLeaves );
116 pGraph->eRoot.Node = iLeaf;
117 pGraph->eRoot.fCompl = fCompl;
118 return pGraph;
119}
ABC_NAMESPACE_IMPL_START Kit_Graph_t * Kit_GraphCreate(int nLeaves)
DECLARATIONS ///.
Definition kitGraph.c:46
unsigned Node
Definition kit.h:66
Here is the call graph for this function:

◆ Kit_GraphFree()

void Kit_GraphFree ( Kit_Graph_t * pGraph)
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file kitGraph.c.

133{
134 ABC_FREE( pGraph->pNodes );
135 ABC_FREE( pGraph );
136}
Here is the caller graph for this function:

◆ Kit_GraphLeafDepth_rec()

int Kit_GraphLeafDepth_rec ( Kit_Graph_t * pGraph,
Kit_Node_t * pNode,
Kit_Node_t * pLeaf )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 412 of file kitGraph.c.

413{
414 int Depth0, Depth1, Depth;
415 if ( pNode == pLeaf )
416 return 0;
417 if ( Kit_GraphNodeIsVar(pGraph, pNode) )
418 return -100;
419 Depth0 = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeFanin0(pGraph, pNode), pLeaf );
420 Depth1 = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeFanin1(pGraph, pNode), pLeaf );
421 Depth = KIT_MAX( Depth0, Depth1 );
422 Depth = (Depth == -100) ? -100 : Depth + 1;
423 return Depth;
424}
int Kit_GraphLeafDepth_rec(Kit_Graph_t *pGraph, Kit_Node_t *pNode, Kit_Node_t *pLeaf)
Definition kitGraph.c:412
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_GraphToTruth()

unsigned Kit_GraphToTruth ( Kit_Graph_t * pGraph)
extern

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

Synopsis [Derives the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file kitGraph.c.

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

◆ Kit_IsopNodeNum()

int Kit_IsopNodeNum ( unsigned * pTruth0,
unsigned * pTruth1,
int nVars,
Vec_Int_t * vMemory )
extern

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file kitHop.c.

140{
141 Kit_Graph_t * pGraph;
142 int nNodes;
143 // transform truth table into the decomposition tree
144 if ( vMemory == NULL )
145 {
146 vMemory = Vec_IntAlloc( 0 );
147 pGraph = Kit_TruthToGraph2( pTruth0, pTruth1, nVars, vMemory );
148 Vec_IntFree( vMemory );
149 }
150 else
151 pGraph = Kit_TruthToGraph2( pTruth0, pTruth1, nVars, vMemory );
152 if ( pGraph == NULL )
153 {
154 printf( "Kit_TruthToGia2(): Converting truth table to AIG has failed for function:\n" );
155 Kit_DsdPrintFromTruth( pTruth0, nVars ); printf( "\n" );
156 Kit_DsdPrintFromTruth( pTruth1, nVars ); printf( "\n" );
157 }
158 // derive the AIG for the decomposition tree
159 nNodes = Kit_GraphNodeNum( pGraph );
160 Kit_GraphFree( pGraph );
161 return nNodes;
162}
Kit_Graph_t * Kit_TruthToGraph2(unsigned *pTruth0, unsigned *pTruth1, int nVars, Vec_Int_t *vMemory)
Definition kitGraph.c:384
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition kitGraph.c:132
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_IsopResub()

Vec_Int_t * Kit_IsopResub ( unsigned * pTruth0,
unsigned * pTruth1,
int nVars,
Vec_Int_t * vMemory )
extern

Definition at line 200 of file kitHop.c.

201{
202 Vec_Int_t * vRes = NULL;
203 Kit_Graph_t * pGraph;
204 int nNodes;
205 // transform truth table into the decomposition tree
206 if ( vMemory == NULL )
207 {
208 vMemory = Vec_IntAlloc( 0 );
209 pGraph = Kit_TruthToGraph2( pTruth0, pTruth1, nVars, vMemory );
210 Vec_IntFree( vMemory );
211 }
212 else
213 pGraph = Kit_TruthToGraph2( pTruth0, pTruth1, nVars, vMemory );
214 if ( pGraph == NULL )
215 {
216 printf( "Kit_TruthToGia2(): Converting truth table to AIG has failed for function:\n" );
217 Kit_DsdPrintFromTruth( pTruth0, nVars ); printf( "\n" );
218 Kit_DsdPrintFromTruth( pTruth1, nVars ); printf( "\n" );
219 }
220 // derive the AIG for the decomposition tree
221 nNodes = Kit_GraphNodeNum( pGraph );
222 vRes = Vec_IntAlloc( 2*nNodes + 1 );
223 Kit_IsopResubInt( pGraph, vRes );
224 assert( Vec_IntSize(vRes) == 2*nNodes + 1 );
225 Kit_GraphFree( pGraph );
226 return vRes;
227}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Kit_IsopResubInt(Kit_Graph_t *pGraph, Vec_Int_t *vRes)
Definition kitHop.c:175
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_PlaComplement()

void Kit_PlaComplement ( char * pSop)
extern

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}
Here is the caller graph for this function:

◆ Kit_PlaCreateFromIsop()

char * Kit_PlaCreateFromIsop ( void * p,
int nVars,
Vec_Int_t * vCover )
extern

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}
struct Aig_MmFlex_t_ Aig_MmFlex_t
Definition aig.h:53
char * Kit_PlaStart(void *p, int nCubes, int nVars)
Definition kitPla.c:211
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_PlaFromTruth()

char * Kit_PlaFromTruth ( void * p,
unsigned * pTruth,
int nVars,
Vec_Int_t * vCover )
extern

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}
void Kit_PlaComplement(char *pSop)
Definition kitPla.c:181
char * Kit_PlaCreateFromIsop(void *p, int nVars, Vec_Int_t *vCover)
Definition kitPla.c:243
char * Kit_PlaStoreSop(void *p, char *pSop)
Definition kitPla.c:317
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_PlaFromTruthNew()

char * Kit_PlaFromTruthNew ( unsigned * pTruth,
int nVars,
Vec_Int_t * vCover,
Vec_Str_t * vStr )
extern

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}
ABC_UINT64_T Kit_PlaToTruth6(char *pSop, int nVars)
Definition kitPla.c:442
char * Kit_PlaFromIsop(Vec_Str_t *vStr, int nVars, Vec_Int_t *vCover)
Definition kitPla.c:366
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_PlaGetCubeNum()

int Kit_PlaGetCubeNum ( char * pSop)
extern

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}
Here is the caller graph for this function:

◆ Kit_PlaGetVarNum()

int Kit_PlaGetVarNum ( char * pSop)
extern

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}
Here is the caller graph for this function:

◆ Kit_PlaIsBuf()

int Kit_PlaIsBuf ( char * pSop)
extern

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}

◆ Kit_PlaIsComplement()

int Kit_PlaIsComplement ( char * pSop)
extern

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}
Here is the caller graph for this function:

◆ Kit_PlaIsConst0()

int Kit_PlaIsConst0 ( char * pSop)
extern

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}
Here is the caller graph for this function:

◆ Kit_PlaIsConst1()

int Kit_PlaIsConst1 ( char * pSop)
extern

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}

◆ Kit_PlaIsInv()

int Kit_PlaIsInv ( char * pSop)
extern

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}

◆ Kit_PlaStart()

char * Kit_PlaStart ( void * p,
int nCubes,
int nVars )
extern

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, '-', (size_t)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 * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition aigMem.c:366
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_PlaStoreSop()

char * Kit_PlaStoreSop ( void * p,
char * pSop )
extern

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}
int strlen()
char * strcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_PlaToIsop()

void Kit_PlaToIsop ( char * pSop,
Vec_Int_t * vCover )
extern

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
Here is the call graph for this function:

◆ Kit_PlaToTruth()

void Kit_PlaToTruth ( char * pSop,
int nVars,
Vec_Ptr_t * vVars,
unsigned * pTemp,
unsigned * pTruth )
extern

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}
Here is the call graph for this function:

◆ Kit_PlaToTruth6()

ABC_UINT64_T Kit_PlaToTruth6 ( char * pSop,
int nVars )
extern

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}
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
int Kit_PlaIsComplement(char *pSop)
Definition kitPla.c:160
int lit
Definition satVec.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_SopAnyLiteral()

int Kit_SopAnyLiteral ( Kit_Sop_t * cSop,
int nLits )
extern

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}
#define Kit_SopForEachCube(cSop, uCube, i)
ITERATORS ///.
Definition kit.h:500
Here is the caller graph for this function:

◆ Kit_SopBestLiteralCover()

void Kit_SopBestLiteralCover ( Kit_Sop_t * cResult,
Kit_Sop_t * cSop,
unsigned uCube,
int nLits,
Vec_Int_t * vMemory )
extern

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
Here is the call graph for this function:

◆ Kit_SopCommonCubeCover()

void Kit_SopCommonCubeCover ( Kit_Sop_t * cResult,
Kit_Sop_t * cSop,
Vec_Int_t * vMemory )
extern

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}

◆ Kit_SopCreate()

void Kit_SopCreate ( Kit_Sop_t * cResult,
Vec_Int_t * vInput,
int nVars,
Vec_Int_t * vMemory )
extern

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}

◆ Kit_SopCreateInverse()

void Kit_SopCreateInverse ( Kit_Sop_t * cResult,
Vec_Int_t * vInput,
int nLits,
Vec_Int_t * vMemory )
extern

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}
Here is the caller graph for this function:

◆ Kit_SopDivideByCube()

void Kit_SopDivideByCube ( Kit_Sop_t * cSop,
Kit_Sop_t * cDiv,
Kit_Sop_t * vQuo,
Kit_Sop_t * vRem,
Vec_Int_t * vMemory )
extern

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}
Here is the caller graph for this function:

◆ Kit_SopDivideByLiteralQuo()

void Kit_SopDivideByLiteralQuo ( Kit_Sop_t * cSop,
int iLit )
extern

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}
Here is the caller graph for this function:

◆ Kit_SopDivideInternal()

void Kit_SopDivideInternal ( Kit_Sop_t * cSop,
Kit_Sop_t * cDiv,
Kit_Sop_t * vQuo,
Kit_Sop_t * vRem,
Vec_Int_t * vMemory )
extern

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}
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
Here is the call graph for this function:

◆ Kit_SopDivisor()

int Kit_SopDivisor ( Kit_Sop_t * cResult,
Kit_Sop_t * cSop,
int nLits,
Vec_Int_t * vMemory )
extern

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}
int Kit_SopAnyLiteral(Kit_Sop_t *cSop, int nLits)
Definition kitSop.c:370
void Kit_SopDup(Kit_Sop_t *cResult, Kit_Sop_t *cSop, Vec_Int_t *vMemory)
Definition kitSop.c:97
void Kit_SopDivisorZeroKernel_rec(Kit_Sop_t *cSop, int nLits)
Definition kitSop.c:509
Here is the call graph for this function:

◆ Kit_SopDup()

void Kit_SopDup ( Kit_Sop_t * cResult,
Kit_Sop_t * cSop,
Vec_Int_t * vMemory )
extern

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}
Here is the caller graph for this function:

◆ Kit_SopFactor()

Kit_Graph_t * Kit_SopFactor ( Vec_Int_t * vCover,
int fCompl,
int nVars,
Vec_Int_t * vMemory )
extern

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 );
74 Vec_IntGrow( vMemory, KIT_FACTOR_MEM_LIMIT );
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
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
Definition kit.h:54
Kit_Graph_t * Kit_GraphCreateConst1()
Definition kitGraph.c:91
void Kit_SopCreateInverse(Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
Definition kitSop.c:68
Kit_Graph_t * Kit_GraphCreate(int nLeaves)
DECLARATIONS ///.
Definition kitGraph.c:46
Kit_Graph_t * Kit_GraphCreateConst0()
Definition kitGraph.c:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_SopIsCubeFree()

int Kit_SopIsCubeFree ( Kit_Sop_t * cSop)
extern

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}

◆ Kit_SopMakeCubeFree()

void Kit_SopMakeCubeFree ( Kit_Sop_t * cSop)
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthBestCofVar()

int Kit_TruthBestCofVar ( unsigned * pTruth,
int nVars,
unsigned * pCof0,
unsigned * pCof1 )
extern

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}
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition kitTruth.c:573
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition kitTruth.c:521
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
Definition kitTruth.c:327
#define KIT_INFINITY
Definition kit.h:176
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthChangePhase()

void Kit_TruthChangePhase ( unsigned * pTruth,
int nVars,
int iVar )
extern

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}
int nWords
Definition abcNpn.c:127
Here is the caller graph for this function:

◆ Kit_TruthCofactor0()

void Kit_TruthCofactor0 ( unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthCofactor0New()

void Kit_TruthCofactor0New ( unsigned * pOut,
unsigned * pIn,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthCofactor1()

void Kit_TruthCofactor1 ( unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthCofactor1New()

void Kit_TruthCofactor1New ( unsigned * pOut,
unsigned * pIn,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthCofSupports()

void Kit_TruthCofSupports ( Vec_Int_t * vBddDir,
Vec_Int_t * vBddInv,
int nVars,
Vec_Int_t * vMemory,
unsigned * puSupps )
extern

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}
int Var
Definition exorList.c:228
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthCompose()

unsigned * Kit_TruthCompose ( CloudManager * dd,
unsigned * pTruth,
int nVars,
unsigned ** pInputs,
int nVarsAll,
Vec_Ptr_t * vStore,
Vec_Int_t * vNodes )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthCountOnesInCofs()

void Kit_TruthCountOnesInCofs ( unsigned * pTruth,
int nVars,
int * pStore )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthCountOnesInCofs0()

void Kit_TruthCountOnesInCofs0 ( unsigned * pTruth,
int nVars,
int * pStore )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthCountOnesInCofsSlow()

void Kit_TruthCountOnesInCofsSlow ( unsigned * pTruth,
int nVars,
int * pStore,
unsigned * pAux )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthDumpToFile()

char * Kit_TruthDumpToFile ( unsigned * pTruth,
int nVars,
int nFile )
extern

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()
Here is the call graph for this function:

◆ Kit_TruthExist()

void Kit_TruthExist ( unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthExistNew()

void Kit_TruthExistNew ( unsigned * pRes,
unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthExistSet()

void Kit_TruthExistSet ( unsigned * pRes,
unsigned * pTruth,
int nVars,
unsigned uMask )
extern

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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthForall()

void Kit_TruthForall ( unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthForallNew()

void Kit_TruthForallNew ( unsigned * pRes,
unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthForallSet()

void Kit_TruthForallSet ( unsigned * pRes,
unsigned * pTruth,
int nVars,
unsigned uMask )
extern

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
Here is the call graph for this function:

◆ Kit_TruthHash()

unsigned Kit_TruthHash ( unsigned * pIn,
int nWords )
extern

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}

◆ Kit_TruthIsop()

int Kit_TruthIsop ( unsigned * puTruth,
int nVars,
Vec_Int_t * vMemory,
int fTryBoth )
extern

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 134 of file kitIsop.c.

135{
136 Kit_Sop_t cRes, * pcRes = &cRes;
137 Kit_Sop_t cRes2, * pcRes2 = &cRes2;
138 unsigned * pResult;
139 int RetValue = 0;
140 assert( nVars >= 0 && nVars <= 16 );
141 // if nVars < 5, make sure it does not depend on those vars
142// for ( i = nVars; i < 5; i++ )
143// assert( !Kit_TruthVarInSupport(puTruth, 5, i) );
144 // prepare memory manager
145 Vec_IntClear( vMemory );
146 Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
147 // compute ISOP for the direct polarity
148 pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes, vMemory );
149 if ( pcRes->nCubes == -1 )
150 {
151 vMemory->nSize = -1;
152 return -1;
153 }
154 assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
155 if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
156 {
157 vMemory->pArray[0] = 0;
158 Vec_IntShrink( vMemory, pcRes->nCubes );
159 return 0;
160 }
161 if ( fTryBoth )
162 {
163 // compute ISOP for the complemented polarity
164 Kit_TruthNot( puTruth, puTruth, nVars );
165 pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes2, vMemory );
166 if ( pcRes2->nCubes >= 0 )
167 {
168 assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
169 if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
170 {
171 RetValue = 1;
172 pcRes = pcRes2;
173 }
174 }
175 Kit_TruthNot( puTruth, puTruth, nVars );
176 }
177// printf( "%d ", vMemory->nSize );
178 // move the cover representation to the beginning of the memory buffer
179 memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
180 Vec_IntShrink( vMemory, pcRes->nCubes );
181 return RetValue;
182}
#define KIT_ISOP_MEM_LIMIT
DECLARATIONS ///.
Definition kitIsop.c:31
char * memmove()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthIsop2()

int Kit_TruthIsop2 ( unsigned * puTruth0,
unsigned * puTruth1,
int nVars,
Vec_Int_t * vMemory,
int fTryBoth,
int fReturnTt )
extern

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 // prepare memory manager
63 Vec_IntClear( vMemory );
64 Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
65 // compute ISOP for the direct polarity
66 Kit_TruthNot( puTruth0, puTruth0, nVars );
67 pResult = Kit_TruthIsop_rec( puTruth1, puTruth0, nVars, pcRes, vMemory );
68 Kit_TruthNot( puTruth0, puTruth0, nVars );
69 if ( pcRes->nCubes == -1 )
70 {
71 vMemory->nSize = -1;
72 return -1;
73 }
74 assert( Kit_TruthIsImply( puTruth1, pResult, nVars ) );
75 Kit_TruthNot( puTruth0, puTruth0, nVars );
76 assert( Kit_TruthIsImply( pResult, puTruth0, nVars ) );
77 Kit_TruthNot( puTruth0, puTruth0, nVars );
78 if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
79 {
80 vMemory->pArray[0] = 0;
81 Vec_IntShrink( vMemory, pcRes->nCubes );
82 return 0;
83 }
84 if ( fTryBoth )
85 {
86 // compute ISOP for the complemented polarity
87 Kit_TruthNot( puTruth1, puTruth1, nVars );
88 pResult = Kit_TruthIsop_rec( puTruth0, puTruth1, nVars, pcRes2, vMemory );
89 Kit_TruthNot( puTruth1, puTruth1, nVars );
90 if ( pcRes2->nCubes >= 0 )
91 {
92 assert( Kit_TruthIsImply( puTruth0, pResult, nVars ) );
93 Kit_TruthNot( puTruth1, puTruth1, nVars );
94 assert( Kit_TruthIsImply( pResult, puTruth1, nVars ) );
95 Kit_TruthNot( puTruth1, puTruth1, nVars );
96 if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
97 {
98 RetValue = 1;
99 pcRes = pcRes2;
100 }
101 }
102 }
103// printf( "%d ", vMemory->nSize );
104 // move the cover representation to the beginning of the memory buffer
105 if ( fReturnTt )
106 {
107 int nWords = Kit_TruthWordNum( nVars );
108 memmove( vMemory->pArray, pResult, nWords * sizeof(unsigned) );
109 Vec_IntShrink( vMemory, nWords );
110 }
111 else
112 {
113 memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
114 Vec_IntShrink( vMemory, pcRes->nCubes );
115 }
116 return RetValue;
117}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthIsopPrint()

void Kit_TruthIsopPrint ( unsigned * puTruth,
int nVars,
Vec_Int_t * vMemory,
int fTryBoth )
extern

Definition at line 207 of file kitIsop.c.

208{
209 int fCompl = Kit_TruthIsop( puTruth, nVars, vCover, fTryBoth );
210 Kit_TruthIsopPrintCover( vCover, nVars, fCompl );
211}
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
Definition kitIsop.c:183
Here is the call graph for this function:

◆ Kit_TruthIsopPrintCover()

void Kit_TruthIsopPrintCover ( Vec_Int_t * vCover,
int nVars,
int fCompl )
extern

Definition at line 183 of file kitIsop.c.

184{
185 int i, k, Entry, Literal;
186 if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0) )
187 {
188 printf( "Constant %d\n", Vec_IntSize(vCover) );
189 return;
190 }
191 Vec_IntForEachEntry( vCover, Entry, i )
192 {
193 for ( k = 0; k < nVars; k++ )
194 {
195 Literal = 3 & (Entry >> (k << 1));
196 if ( Literal == 1 ) // neg literal
197 printf( "0" );
198 else if ( Literal == 2 ) // pos literal
199 printf( "1" );
200 else if ( Literal == 0 )
201 printf( "-" );
202 else assert( 0 );
203 }
204 printf( " %d\n", !fCompl );
205 }
206}
Here is the caller graph for this function:

◆ Kit_TruthLitNum()

int Kit_TruthLitNum ( unsigned * pTruth,
int nVars,
Vec_Int_t * vMemory )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 511 of file kitGraph.c.

512{
513 Kit_Graph_t * pGraph;
514 int RetValue, nLits;
515 RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 1 );
516 if ( RetValue == -1 || Vec_IntSize(vMemory) > (1<<16) )
517 return -1;
518 assert( RetValue == 0 || RetValue == 1 );
519 pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory );
520 nLits = 1 + Kit_GraphNodeNum( pGraph );
521 Kit_GraphFree( pGraph );
522 return nLits;
523}
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition kitGraph.c:132
Kit_Graph_t * Kit_SopFactor(Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
FUNCTION DEFINITIONS ///.
Definition kitFactor.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthMinCofSuppOverlap()

int Kit_TruthMinCofSuppOverlap ( unsigned * pTruth,
int nVars,
int * pVarMin )
extern

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_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
Definition kitTruth.c:368
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition kitTruth.c:346
void Kit_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
Definition kitTruth.c:470
Here is the call graph for this function:

◆ Kit_TruthMuxVar()

void Kit_TruthMuxVar ( unsigned * pOut,
unsigned * pCof0,
unsigned * pCof1,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthMuxVarPhase()

void Kit_TruthMuxVarPhase ( unsigned * pOut,
unsigned * pCof0,
unsigned * pCof1,
int nVars,
int iVar,
int fCompl0 )
extern

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}
void Kit_TruthMuxVar(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
Definition kitTruth.c:1069
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthPermute()

void Kit_TruthPermute ( unsigned * pOut,
unsigned * pIn,
int nVars,
char * pPerm,
int fReturnIn )
extern

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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthPrintProfile()

void Kit_TruthPrintProfile ( unsigned * pTruth,
int nVars )
extern

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(unsigned *pTruth, int nVars)
Definition kitTruth.c:2203
void Kit_TruthPrintProfile_int(unsigned *pTruth, int nVars)
Definition kitTruth.c:2029
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthSemiCanonicize()

unsigned Kit_TruthSemiCanonicize ( unsigned * pInOut,
unsigned * pAux,
int nVars,
char * pCanonPerm )
extern

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}
void Kit_TruthCountOnesInCofs(unsigned *pTruth, int nVars, int *pStore)
Definition kitTruth.c:1410
void Kit_TruthChangePhase(unsigned *pTruth, int nVars, int iVar)
Definition kitTruth.c:1259
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthShrink()

void Kit_TruthShrink ( unsigned * pOut,
unsigned * pIn,
int nVars,
int nVarsAll,
unsigned Phase,
int fReturnIn )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthStretch()

void Kit_TruthStretch ( unsigned * pOut,
unsigned * pIn,
int nVars,
int nVarsAll,
unsigned Phase,
int fReturnIn )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthSupport()

unsigned Kit_TruthSupport ( unsigned * pTruth,
int nVars )
extern

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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthSupportSize()

int Kit_TruthSupportSize ( unsigned * pTruth,
int nVars )
extern

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthSwapAdjacentVars()

void Kit_TruthSwapAdjacentVars ( unsigned * pOut,
unsigned * pIn,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthToCloud()

CloudNode * Kit_TruthToCloud ( CloudManager * dd,
unsigned * pTruth,
int nVars )
extern

FUNCTION DECLARATIONS ///.

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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthToGraph()

Kit_Graph_t * Kit_TruthToGraph ( unsigned * pTruth,
int nVars,
Vec_Int_t * vMemory )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 356 of file kitGraph.c.

357{
358 Kit_Graph_t * pGraph;
359 int RetValue;
360 // derive SOP
361 RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 1 ); // tried 1 and found not useful in "renode"
362 if ( RetValue == -1 )
363 return NULL;
364 if ( Vec_IntSize(vMemory) > (1<<16) )
365 return NULL;
366// printf( "Isop size = %d.\n", Vec_IntSize(vMemory) );
367 assert( RetValue == 0 || RetValue == 1 );
368 // derive factored form
369 pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory );
370 return pGraph;
371}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthToGraph2()

Kit_Graph_t * Kit_TruthToGraph2 ( unsigned * pTruth0,
unsigned * pTruth1,
int nVars,
Vec_Int_t * vMemory )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 384 of file kitGraph.c.

385{
386 Kit_Graph_t * pGraph;
387 int RetValue;
388 // derive SOP
389 RetValue = Kit_TruthIsop2( pTruth0, pTruth1, nVars, vMemory, 0, 0 ); // tried 1 and found not useful in "renode"
390 if ( RetValue == -1 )
391 return NULL;
392 if ( Vec_IntSize(vMemory) > (1<<16) )
393 return NULL;
394// printf( "Isop size = %d.\n", Vec_IntSize(vMemory) );
395 assert( RetValue == 0 || RetValue == 1 );
396 // derive factored form
397 pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory );
398 return pGraph;
399}
int Kit_TruthIsop2(unsigned *puTruth0, unsigned *puTruth1, int nVars, Vec_Int_t *vMemory, int fTryBoth, int fReturnTt)
FUNCTION DEFINITIONS ///.
Definition kitIsop.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Kit_TruthUniqueNew()

void Kit_TruthUniqueNew ( unsigned * pRes,
unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthVarInSupport()

int Kit_TruthVarInSupport ( unsigned * pTruth,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthVarIsVacuous()

int Kit_TruthVarIsVacuous ( unsigned * pOnset,
unsigned * pOffset,
int nVars,
int iVar )
extern

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}
Here is the caller graph for this function:

◆ Kit_TruthVarsAntiSymm()

int Kit_TruthVarsAntiSymm ( unsigned * pTruth,
int nVars,
int iVar0,
int iVar1,
unsigned * pCof0,
unsigned * pCof1 )
extern

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}
Here is the call graph for this function:

◆ Kit_TruthVarsSymm()

int Kit_TruthVarsSymm ( unsigned * pTruth,
int nVars,
int iVar0,
int iVar1,
unsigned * pCof0,
unsigned * pCof1 )
extern

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}
Here is the call graph for this function: