abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
if.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "misc/mem/mem.h"
#include "misc/tim/tim.h"
#include "misc/util/utilNam.h"
#include "misc/vec/vecMem.h"
#include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"
#include "misc/vec/vecHash.h"
#include "misc/vec/vecWec.h"

Go to the source code of this file.

Data Structures

struct  Ifif_Par_t_
 
struct  If_Par_t_
 
struct  If_LibLut_t_
 
struct  If_Man_t_
 
struct  If_Cut_t_
 
struct  If_Set_t_
 
struct  If_Obj_t_
 
struct  If_Box_t_
 
struct  If_LibBox_t_
 

Macros

#define IF_MAX_LUTSIZE   32
 INCLUDES ///. More...
 
#define IF_MAX_FUNC_LUTSIZE   15
 
#define IF_INFINITY   100000000
 
#define IF_COST_MAX   8191
 
#define IF_BIG_CHAR   ((char)120)
 
#define IF_MIN(a, b)   (((a) < (b))? (a) : (b))
 MACRO DEFINITIONS ///. More...
 
#define IF_MAX(a, b)   (((a) > (b))? (a) : (b))
 
#define IF_FLOAT_LARGE   ((float)1.0e+20)
 
#define IF_FLOAT_SMALL   ((float)1.0e-20)
 
#define IF_INT_LARGE   (10000000)
 
#define If_ManForEachCi(p, pObj, i)   Vec_PtrForEachEntry( If_Obj_t *, p->vCis, pObj, i )
 
#define If_ManForEachCo(p, pObj, i)   Vec_PtrForEachEntry( If_Obj_t *, p->vCos, pObj, i )
 
#define If_ManForEachPi(p, pObj, i)   Vec_PtrForEachEntryStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox )
 
#define If_ManForEachPo(p, pObj, i)   Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCos, pObj, i, p->pPars->nLatchesCoBox, If_ManCoNum(p) - p->pPars->nLatchesCo )
 
#define If_ManForEachLatchInput(p, pObj, i)   Vec_PtrForEachEntryStart( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatchesCo )
 
#define If_ManForEachLatchOutput(p, pObj, i)   Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox, If_ManCiNum(p) - p->pPars->nLatchesCiBox )
 
#define If_ManForEachObj(p, pObj, i)   Vec_PtrForEachEntry( If_Obj_t *, p->vObjs, pObj, i )
 
#define If_ManForEachObjReverse(p, pObj, i)   Vec_PtrForEachEntry( If_Obj_t *, p->vObjsRev, pObj, i )
 
#define If_ManForEachNode(p, pObj, i)   If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
 
#define If_ObjForEachCut(pObj, pCut, i)   for ( i = 0; (i < (pObj)->pCutSet->nCuts) && ((pCut) = (pObj)->pCutSet->ppCuts[i]); i++ )
 
#define If_CutForEachLeaf(p, pCut, pLeaf, i)   for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )
 
#define If_CutForEachLeafReverse(p, pCut, pLeaf, i)   for ( i = (int)(pCut)->nLeaves - 1; (i >= 0) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i-- )
 
#define If_CutForEachLeafSeq(p, pCut, pLeaf, Shift, i)   for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i] >> 8)) && (((Shift) = ((pCut)->pLeaves[i] & 255)) >= 0); i++ )
 

Typedefs

typedef struct If_Man_t_ If_Man_t
 BASIC TYPES ///. More...
 
typedef struct If_Par_t_ If_Par_t
 
typedef struct If_Obj_t_ If_Obj_t
 
typedef struct If_Cut_t_ If_Cut_t
 
typedef struct If_Set_t_ If_Set_t
 
typedef struct If_LibLut_t_ If_LibLut_t
 
typedef struct If_LibBox_t_ If_LibBox_t
 
typedef struct If_DsdMan_t_ If_DsdMan_t
 
typedef struct Ifn_Ntk_t_ Ifn_Ntk_t
 
typedef struct Ifif_Par_t_ Ifif_Par_t
 
typedef struct If_Box_t_ If_Box_t
 

Enumerations

enum  If_Type_t {
  IF_NONE, IF_CONST1, IF_CI, IF_CO,
  IF_AND, IF_VOID
}
 

Functions

static If_Obj_tIf_Regular (If_Obj_t *p)
 
static If_Obj_tIf_Not (If_Obj_t *p)
 
static If_Obj_tIf_NotCond (If_Obj_t *p, int c)
 
static int If_IsComplement (If_Obj_t *p)
 
static int If_ManCiNum (If_Man_t *p)
 
static int If_ManCoNum (If_Man_t *p)
 
static int If_ManAndNum (If_Man_t *p)
 
static int If_ManObjNum (If_Man_t *p)
 
static If_Obj_tIf_ManConst1 (If_Man_t *p)
 
static If_Obj_tIf_ManCi (If_Man_t *p, int i)
 
static If_Obj_tIf_ManCo (If_Man_t *p, int i)
 
static If_Obj_tIf_ManLi (If_Man_t *p, int i)
 
static If_Obj_tIf_ManLo (If_Man_t *p, int i)
 
static If_Obj_tIf_ManObj (If_Man_t *p, int i)
 
static int If_ObjIsConst1 (If_Obj_t *pObj)
 
static int If_ObjIsCi (If_Obj_t *pObj)
 
static int If_ObjIsCo (If_Obj_t *pObj)
 
static int If_ObjIsTerm (If_Obj_t *pObj)
 
static int If_ObjIsLatch (If_Obj_t *pObj)
 
static int If_ObjIsAnd (If_Obj_t *pObj)
 
static int If_ObjId (If_Obj_t *pObj)
 
static If_Obj_tIf_ObjFanin0 (If_Obj_t *pObj)
 
static If_Obj_tIf_ObjFanin1 (If_Obj_t *pObj)
 
static int If_ObjFaninC0 (If_Obj_t *pObj)
 
static int If_ObjFaninC1 (If_Obj_t *pObj)
 
static void * If_ObjCopy (If_Obj_t *pObj)
 
static int If_ObjLevel (If_Obj_t *pObj)
 
static void If_ObjSetLevel (If_Obj_t *pObj, int Level)
 
static void If_ObjSetCopy (If_Obj_t *pObj, void *pCopy)
 
static void If_ObjSetChoice (If_Obj_t *pObj, If_Obj_t *pEqu)
 
static int If_CutLeaveNum (If_Cut_t *pCut)
 
static int * If_CutLeaves (If_Cut_t *pCut)
 
static If_Obj_tIf_CutLeaf (If_Man_t *p, If_Cut_t *pCut, int i)
 
static unsigned If_CutSuppMask (If_Cut_t *pCut)
 
static int If_CutTruthWords (int nVarsMax)
 
static int If_CutPermWords (int nVarsMax)
 
static int If_CutLeafBit (If_Cut_t *pCut, int i)
 
static char * If_CutPerm (If_Cut_t *pCut)
 
static void If_CutCopy (If_Man_t *p, If_Cut_t *pDst, If_Cut_t *pSrc)
 
static void If_CutSetup (If_Man_t *p, If_Cut_t *pCut)
 
static If_Cut_tIf_ObjCutBest (If_Obj_t *pObj)
 
static unsigned If_ObjCutSign (unsigned ObjId)
 
static unsigned If_ObjCutSignCompute (If_Cut_t *p)
 
static float If_ObjArrTime (If_Obj_t *pObj)
 
static void If_ObjSetArrTime (If_Obj_t *pObj, float ArrTime)
 
static float If_ObjLValue (If_Obj_t *pObj)
 
static void If_ObjSetLValue (If_Obj_t *pObj, float LValue)
 
static void * If_CutData (If_Cut_t *pCut)
 
static void If_CutSetData (If_Cut_t *pCut, void *pData)
 
static int If_CutDataInt (If_Cut_t *pCut)
 
static void If_CutSetDataInt (If_Cut_t *pCut, int Data)
 
static int If_CutTruthLit (If_Cut_t *pCut)
 
static int If_CutTruthIsCompl (If_Cut_t *pCut)
 
static wordIf_CutTruthWR (If_Man_t *p, If_Cut_t *pCut)
 
static unsigned * If_CutTruthUR (If_Man_t *p, If_Cut_t *pCut)
 
static wordIf_CutTruthW (If_Man_t *p, If_Cut_t *pCut)
 
static unsigned * If_CutTruth (If_Man_t *p, If_Cut_t *pCut)
 
static int If_CutDsdLit (If_Man_t *p, If_Cut_t *pCut)
 
static int If_CutDsdIsCompl (If_Man_t *p, If_Cut_t *pCut)
 
static char * If_CutDsdPerm (If_Man_t *p, If_Cut_t *pCut)
 
static float If_CutLutArea (If_Man_t *p, If_Cut_t *pCut)
 
static float If_CutLutDelay (If_LibLut_t *p, int Size, int iPin)
 
void If_ManSetDefaultPars (If_Par_t *pPars)
 FUNCTION DECLARATIONS ///. More...
 
int If_ManPerformMapping (If_Man_t *p)
 
int If_ManPerformMappingComb (If_Man_t *p)
 
void If_ManComputeSwitching (If_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
int If_CutVerifyCuts (If_Set_t *pCutSet, int fOrdered)
 
int If_CutFilter (If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
 
void If_CutSort (If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
 
void If_CutOrder (If_Cut_t *pCut)
 
int If_CutMergeOrdered (If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
 
int If_CutMerge (If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
 
int If_CutCheck (If_Cut_t *pCut)
 
void If_CutPrint (If_Cut_t *pCut)
 
void If_CutPrintTiming (If_Man_t *p, If_Cut_t *pCut)
 
void If_CutLift (If_Cut_t *pCut)
 
float If_CutAreaFlow (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeFlow (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutPowerFlow (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutAverageRefs (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaDeref (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaRef (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaDerefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutAreaRefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeDeref (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeRef (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeDerefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutEdgeRefed (If_Man_t *p, If_Cut_t *pCut)
 
float If_CutPowerDeref (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutPowerRef (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutPowerDerefed (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
float If_CutPowerRefed (If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
 
word If_CutPerformDerive07 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck07 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck08 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck10 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck16 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck45 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck54 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
int If_CutPerformCheck75 (If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
 
float If_CutDelayLutStruct (If_Man_t *p, If_Cut_t *pCut, char *pStr, float WireDelay)
 
int If_CluCheckExt (void *p, word *pTruth, int nVars, int nLutLeaf, int nLutRoot, char *pLut0, char *pLut1, word *pFunc0, word *pFunc1)
 
int If_CluCheckExt3 (void *p, word *pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, char *pLut0, char *pLut1, char *pLut2, word *pFunc0, word *pFunc1, word *pFunc2)
 
int If_CutDelaySop (If_Man_t *p, If_Cut_t *pCut)
 
int If_CutSopBalanceEvalInt (Vec_Int_t *vCover, int *pTimes, int *pFaninLits, Vec_Int_t *vAig, int *piRes, int nSuppAll, int *pArea)
 
int If_CutSopBalanceEval (If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
 
int If_CutSopBalancePinDelaysInt (Vec_Int_t *vCover, int *pTimes, word *pFaninRes, int nSuppAll, word *pRes)
 
int If_CutSopBalancePinDelays (If_Man_t *p, If_Cut_t *pCut, char *pPerm)
 
int If_CutLutBalanceEval (If_Man_t *p, If_Cut_t *pCut)
 
int If_CutLutBalancePinDelays (If_Man_t *p, If_Cut_t *pCut, char *pPerm)
 
If_DsdMan_tIf_DsdManAlloc (int nVars, int nLutSize)
 
void If_DsdManAllocIsops (If_DsdMan_t *p, int nLutSize)
 
void If_DsdManPrint (If_DsdMan_t *p, char *pFileName, int Number, int Support, int fOccurs, int fTtDump, int fVerbose)
 
void If_DsdManTune (If_DsdMan_t *p, int LutSize, int fFast, int fAdd, int fSpec, int fVerbose)
 
void Id_DsdManTuneStr (If_DsdMan_t *p, char *pStruct, int nConfls, int nProcs, int fVerbose)
 
void If_DsdManFree (If_DsdMan_t *p, int fVerbose)
 
void If_DsdManSave (If_DsdMan_t *p, char *pFileName)
 
If_DsdMan_tIf_DsdManLoad (char *pFileName)
 
void If_DsdManMerge (If_DsdMan_t *p, If_DsdMan_t *pNew)
 
void If_DsdManCleanOccur (If_DsdMan_t *p, int fVerbose)
 
void If_DsdManCleanMarks (If_DsdMan_t *p, int fVerbose)
 
void If_DsdManInvertMarks (If_DsdMan_t *p, int fVerbose)
 
If_DsdMan_tIf_DsdManFilter (If_DsdMan_t *p, int Limit)
 
int If_DsdManCompute (If_DsdMan_t *p, word *pTruth, int nLeaves, unsigned char *pPerm, char *pLutStruct)
 
char * If_DsdManFileName (If_DsdMan_t *p)
 FUNCTION DEFINITIONS ///. More...
 
int If_DsdManVarNum (If_DsdMan_t *p)
 
int If_DsdManObjNum (If_DsdMan_t *p)
 
int If_DsdManLutSize (If_DsdMan_t *p)
 
void If_DsdManSetLutSize (If_DsdMan_t *p, int nLutSize)
 
int If_DsdManSuppSize (If_DsdMan_t *p, int iDsd)
 
int If_DsdManCheckDec (If_DsdMan_t *p, int iDsd)
 
int If_DsdManReadMark (If_DsdMan_t *p, int iDsd)
 
void If_DsdManSetNewAsUseless (If_DsdMan_t *p)
 
word If_DsdManGetFuncPerm (If_DsdMan_t *p, int iDsd)
 
char * If_DsdManGetCellStr (If_DsdMan_t *p)
 
unsigned If_DsdManCheckXY (If_DsdMan_t *p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose)
 
int If_CutDsdBalanceEval (If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
 
int If_CutDsdBalancePinDelays (If_Man_t *p, If_Cut_t *pCut, char *pPerm)
 
If_LibLut_tIf_LibLutRead (char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
If_LibLut_tIf_LibLutDup (If_LibLut_t *p)
 
void If_LibLutFree (If_LibLut_t *pLutLib)
 
void If_LibLutPrint (If_LibLut_t *pLutLib)
 
int If_LibLutDelaysAreDiscrete (If_LibLut_t *pLutLib)
 
int If_LibLutDelaysAreDifferent (If_LibLut_t *pLutLib)
 
If_LibLut_tIf_LibLutSetSimple (int nLutSize)
 
float If_LibLutFastestPinDelay (If_LibLut_t *p)
 
float If_LibLutSlowestPinDelay (If_LibLut_t *p)
 
If_LibBox_tIf_LibBoxStart ()
 
void If_LibBoxFree (If_LibBox_t *p)
 
If_Box_tIf_LibBoxReadBox (If_LibBox_t *p, int Id)
 
If_Box_tIf_LibBoxFindBox (If_LibBox_t *p, char *pName)
 
void If_LibBoxAdd (If_LibBox_t *p, If_Box_t *pBox)
 
If_LibBox_tIf_LibBoxRead (char *pFileName)
 
If_LibBox_tIf_LibBoxRead2 (char *pFileName)
 
void If_LibBoxPrint (FILE *pFile, If_LibBox_t *p)
 
void If_LibBoxWrite (char *pFileName, If_LibBox_t *p)
 
int If_LibBoxLoad (char *pFileName)
 
If_Man_tIf_ManStart (If_Par_t *pPars)
 FUNCTION DEFINITIONS ///. More...
 
void If_ManRestart (If_Man_t *p)
 
void If_ManStop (If_Man_t *p)
 
If_Obj_tIf_ManCreateCi (If_Man_t *p)
 
If_Obj_tIf_ManCreateCo (If_Man_t *p, If_Obj_t *pDriver)
 
If_Obj_tIf_ManCreateAnd (If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
 
If_Obj_tIf_ManCreateXor (If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
 
If_Obj_tIf_ManCreateMux (If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1, If_Obj_t *pCtrl)
 
void If_ManCreateChoice (If_Man_t *p, If_Obj_t *pRepr)
 
void If_ManSetupCutTriv (If_Man_t *p, If_Cut_t *pCut, int ObjId)
 
void If_ManSetupCiCutSets (If_Man_t *p)
 
If_Set_tIf_ManSetupNodeCutSet (If_Man_t *p, If_Obj_t *pObj)
 
void If_ManDerefNodeCutSet (If_Man_t *p, If_Obj_t *pObj)
 
void If_ManDerefChoiceCutSet (If_Man_t *p, If_Obj_t *pObj)
 
void If_ManSetupSetAll (If_Man_t *p, int nCrossCut)
 
void If_ObjPerformMappingAnd (If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
 
void If_ObjPerformMappingChoice (If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
 
int If_ManPerformMappingRound (If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
 
void If_ManImproveMapping (If_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void * If_ManSatBuildXY (int nLutSize)
 DECLARATIONS ///. More...
 
void * If_ManSatBuildXYZ (int nLutSize)
 
void If_ManSatUnbuild (void *p)
 
int If_ManSatCheckXY (void *pSat, int nLutSize, word *pTruth, int nVars, unsigned uSet, word *pTBound, word *pTFree, Vec_Int_t *vLits)
 
unsigned If_ManSatCheckXYall (void *pSat, int nLutSize, word *pTruth, int nVars, Vec_Int_t *vLits)
 
int If_ManPerformMappingSeq (If_Man_t *p)
 
float If_CutDelay (If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
 
void If_CutPropagateRequired (If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut, float Required)
 
float If_ManDelayMax (If_Man_t *p, int fSeq)
 
void If_ManComputeRequired (If_Man_t *p)
 
void If_CutRotatePins (If_Man_t *p, If_Cut_t *pCut)
 
int If_CutComputeTruth (If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
 
int If_CutComputeTruthPerm (If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
 
Ifn_Ntk_tIfn_NtkParse (char *pStr)
 
int Ifn_NtkMatch (Ifn_Ntk_t *p, word *pTruth, int nVars, int nConfls, int fVerbose, int fVeryVerbose, word *pPerm)
 
void Ifn_NtkPrint (Ifn_Ntk_t *p)
 
int Ifn_NtkLutSizeMax (Ifn_Ntk_t *p)
 
int Ifn_NtkInputNum (Ifn_Ntk_t *p)
 
void * If_ManSatBuildFromCell (char *pStr, Vec_Int_t **pvPiVars, Vec_Int_t **pvPoVars, Ifn_Ntk_t **ppNtk)
 
int If_ManSatFindCofigBits (void *pSat, Vec_Int_t *vPiVars, Vec_Int_t *vPoVars, word *pTruth, int nVars, word Perm, int nInps, Vec_Int_t *vValues)
 
int If_ManSatDeriveGiaFromBits (void *pNew, Ifn_Ntk_t *p, Vec_Int_t *vLeaves, Vec_Int_t *vValues)
 
void If_ManCleanNodeCopy (If_Man_t *p)
 DECLARATIONS ///. More...
 
void If_ManCleanCutData (If_Man_t *p)
 
void If_ManCleanMarkV (If_Man_t *p)
 
float If_ManScanMapping (If_Man_t *p)
 
float If_ManScanMappingDirect (If_Man_t *p)
 
float If_ManScanMappingSeq (If_Man_t *p)
 
void If_ManResetOriginalRefs (If_Man_t *p)
 
int If_ManCrossCut (If_Man_t *p)
 
Vec_Ptr_tIf_ManReverseOrder (If_Man_t *p)
 
void If_ManMarkMapping (If_Man_t *p)
 
Vec_Ptr_tIf_ManCollectMappingDirect (If_Man_t *p)
 
Vec_Int_tIf_ManCollectMappingInt (If_Man_t *p)
 
int If_ManCountSpecialPos (If_Man_t *p)
 
void If_CutTraverse (If_Man_t *p, If_Obj_t *pRoot, If_Cut_t *pCut, Vec_Ptr_t *vNodes)
 
void If_ObjPrint (If_Obj_t *pObj)
 

Macro Definition Documentation

#define IF_BIG_CHAR   ((char)120)

Definition at line 60 of file if.h.

#define IF_COST_MAX   8191

Definition at line 58 of file if.h.

#define If_CutForEachLeaf (   p,
  pCut,
  pLeaf,
 
)    for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )

Definition at line 474 of file if.h.

#define If_CutForEachLeafReverse (   p,
  pCut,
  pLeaf,
 
)    for ( i = (int)(pCut)->nLeaves - 1; (i >= 0) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i-- )

Definition at line 476 of file if.h.

#define If_CutForEachLeafSeq (   p,
  pCut,
  pLeaf,
  Shift,
 
)    for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i] >> 8)) && (((Shift) = ((pCut)->pLeaves[i] & 255)) >= 0); i++ )

Definition at line 481 of file if.h.

#define IF_FLOAT_LARGE   ((float)1.0e+20)

Definition at line 440 of file if.h.

#define IF_FLOAT_SMALL   ((float)1.0e-20)

Definition at line 441 of file if.h.

#define IF_INFINITY   100000000

Definition at line 56 of file if.h.

#define IF_INT_LARGE   (10000000)

Definition at line 442 of file if.h.

#define If_ManForEachCi (   p,
  pObj,
 
)    Vec_PtrForEachEntry( If_Obj_t *, p->vCis, pObj, i )

Definition at line 445 of file if.h.

#define If_ManForEachCo (   p,
  pObj,
 
)    Vec_PtrForEachEntry( If_Obj_t *, p->vCos, pObj, i )

Definition at line 448 of file if.h.

#define If_ManForEachLatchInput (   p,
  pObj,
 
)    Vec_PtrForEachEntryStart( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatchesCo )

Definition at line 457 of file if.h.

#define If_ManForEachLatchOutput (   p,
  pObj,
 
)    Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox, If_ManCiNum(p) - p->pPars->nLatchesCiBox )

Definition at line 459 of file if.h.

#define If_ManForEachNode (   p,
  pObj,
 
)    If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else

Definition at line 468 of file if.h.

#define If_ManForEachObj (   p,
  pObj,
 
)    Vec_PtrForEachEntry( If_Obj_t *, p->vObjs, pObj, i )

Definition at line 462 of file if.h.

#define If_ManForEachObjReverse (   p,
  pObj,
 
)    Vec_PtrForEachEntry( If_Obj_t *, p->vObjsRev, pObj, i )

Definition at line 465 of file if.h.

#define If_ManForEachPi (   p,
  pObj,
 
)    Vec_PtrForEachEntryStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox )

Definition at line 451 of file if.h.

#define If_ManForEachPo (   p,
  pObj,
 
)    Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCos, pObj, i, p->pPars->nLatchesCoBox, If_ManCoNum(p) - p->pPars->nLatchesCo )

Definition at line 454 of file if.h.

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

Definition at line 437 of file if.h.

#define IF_MAX_FUNC_LUTSIZE   15

Definition at line 54 of file if.h.

#define IF_MAX_LUTSIZE   32

INCLUDES ///.

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

FileName [if.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id:
if.h,v 1.00 2006/11/21 00:00:00 alanmi Exp

]PARAMETERS ///

Definition at line 52 of file if.h.

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

MACRO DEFINITIONS ///.

Definition at line 436 of file if.h.

#define If_ObjForEachCut (   pObj,
  pCut,
 
)    for ( i = 0; (i < (pObj)->pCutSet->nCuts) && ((pCut) = (pObj)->pCutSet->ppCuts[i]); i++ )

Definition at line 471 of file if.h.

Typedef Documentation

typedef struct If_Box_t_ If_Box_t

Definition at line 336 of file if.h.

typedef struct If_Cut_t_ If_Cut_t

Definition at line 79 of file if.h.

typedef struct If_DsdMan_t_ If_DsdMan_t

Definition at line 83 of file if.h.

typedef struct If_LibBox_t_ If_LibBox_t

Definition at line 82 of file if.h.

typedef struct If_LibLut_t_ If_LibLut_t

Definition at line 81 of file if.h.

typedef struct If_Man_t_ If_Man_t

BASIC TYPES ///.

Definition at line 76 of file if.h.

typedef struct If_Obj_t_ If_Obj_t

Definition at line 78 of file if.h.

typedef struct If_Par_t_ If_Par_t

Definition at line 77 of file if.h.

typedef struct If_Set_t_ If_Set_t

Definition at line 80 of file if.h.

typedef struct Ifif_Par_t_ Ifif_Par_t

Definition at line 86 of file if.h.

typedef struct Ifn_Ntk_t_ Ifn_Ntk_t

Definition at line 84 of file if.h.

Enumeration Type Documentation

enum If_Type_t
Enumerator
IF_NONE 
IF_CONST1 
IF_CI 
IF_CO 
IF_AND 
IF_VOID 

Definition at line 63 of file if.h.

63  {
64  IF_NONE, // 0: non-existent object
65  IF_CONST1, // 1: constant 1
66  IF_CI, // 2: combinational input
67  IF_CO, // 3: combinational output
68  IF_AND, // 4: AND node
69  IF_VOID // 5: unused object
70 } If_Type_t;
Definition: if.h:68
Definition: if.h:69
Definition: if.h:64
Definition: if.h:67
If_Type_t
Definition: if.h:63
Definition: if.h:66
Definition: if.h:65

Function Documentation

void Id_DsdManTuneStr ( If_DsdMan_t p,
char *  pStruct,
int  nConfls,
int  nProcs,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2519 of file ifDsd.c.

2520 {
2521  Id_DsdManTuneStr1( p, pStruct, nConfls, fVerbose );
2522 }
void Id_DsdManTuneStr1(If_DsdMan_t *p, char *pStruct, int nConfls, int fVerbose)
Definition: ifDsd.c:2435
int If_CluCheckExt ( void *  p,
word pTruth,
int  nVars,
int  nLutLeaf,
int  nLutRoot,
char *  pLut0,
char *  pLut1,
word pFunc0,
word pFunc1 
)

Definition at line 2066 of file ifDec16.c.

2068 {
2069  If_Man_t * p = (If_Man_t *)pMan;
2070  If_Grp_t G, R;
2071  G = If_CluCheck( p, pTruth, nVars, 0, 0, nLutLeaf, nLutRoot, &R, pFunc0, pFunc1, NULL, 0 );
2072  memcpy( pLut0, &R, sizeof(If_Grp_t) );
2073  memcpy( pLut1, &G, sizeof(If_Grp_t) );
2074 // memcpy( pLut2, &G2, sizeof(If_Grp_t) );
2075  return (G.nVars > 0);
2076 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
If_Grp_t If_CluCheck(If_Man_t *p, word *pTruth0, int nVars, int iVarStart, int iVarStop, int nLutLeaf, int nLutRoot, If_Grp_t *pR, word *pFunc0, word *pFunc1, word *pLeftOver, int fHashing)
Definition: ifDec16.c:1553
char * memcpy()
Definition: if.h:180
char nVars
Definition: ifDec16.c:40
int If_CluCheckExt3 ( void *  p,
word pTruth,
int  nVars,
int  nLutLeaf,
int  nLutLeaf2,
int  nLutRoot,
char *  pLut0,
char *  pLut1,
char *  pLut2,
word pFunc0,
word pFunc1,
word pFunc2 
)

Definition at line 2079 of file ifDec16.c.

2081 {
2082  If_Man_t * p = (If_Man_t *)pMan;
2083  If_Grp_t G, G2, R;
2084  G = If_CluCheck3( p, pTruth, nVars, nLutLeaf, nLutLeaf2, nLutRoot, &R, &G2, pFunc0, pFunc1, pFunc2 );
2085  memcpy( pLut0, &R, sizeof(If_Grp_t) );
2086  memcpy( pLut1, &G, sizeof(If_Grp_t) );
2087  memcpy( pLut2, &G2, sizeof(If_Grp_t) );
2088  return (G.nVars > 0);
2089 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * memcpy()
If_Grp_t If_CluCheck3(If_Man_t *p, word *pTruth0, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, If_Grp_t *pR, If_Grp_t *pG2, word *pFunc0, word *pFunc1, word *pFunc2)
Definition: ifDec16.c:1909
Definition: if.h:180
char nVars
Definition: ifDec16.c:40
float If_CutAreaDeref ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1032 of file ifCut.c.

1033 {
1034  If_Obj_t * pLeaf;
1035  float Area;
1036  int i;
1037  Area = If_CutLutArea(p, pCut);
1038  If_CutForEachLeaf( p, pCut, pLeaf, i )
1039  {
1040  assert( pLeaf->nRefs > 0 );
1041  if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) )
1042  continue;
1043  Area += If_CutAreaDeref( p, If_ObjCutBest(pLeaf) );
1044  }
1045  return Area;
1046 }
static float If_CutLutArea(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:428
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int nRefs
Definition: if.h:318
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
#define assert(ex)
Definition: util_old.h:213
float If_CutAreaDerefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1086 of file ifCut.c.

1087 {
1088  float aResult, aResult2;
1089  if ( pCut->nLeaves < 2 )
1090  return 0;
1091  aResult2 = If_CutAreaRef( p, pCut );
1092  aResult = If_CutAreaDeref( p, pCut );
1093  assert( aResult > aResult2 - p->fEpsilon );
1094  assert( aResult < aResult2 + p->fEpsilon );
1095  return aResult;
1096 }
unsigned nLeaves
Definition: if.h:289
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float fEpsilon
Definition: if.h:195
#define assert(ex)
Definition: util_old.h:213
float If_CutAreaFlow ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area flow.]

Description []

SideEffects []

SeeAlso []

Definition at line 919 of file ifCut.c.

920 {
921  If_Obj_t * pLeaf;
922  float Flow;
923  int i;
924  Flow = If_CutLutArea(p, pCut);
925  If_CutForEachLeaf( p, pCut, pLeaf, i )
926  {
927  if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
928  Flow += If_ObjCutBest(pLeaf)->Area;
929  else
930  {
931  assert( pLeaf->EstRefs > p->fEpsilon );
932  Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs;
933  }
934  }
935  return Flow;
936 }
static float If_CutLutArea(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:428
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int nRefs
Definition: if.h:318
float fEpsilon
Definition: if.h:195
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
float Area
Definition: if.h:277
float If_CutAreaRef ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1059 of file ifCut.c.

1060 {
1061  If_Obj_t * pLeaf;
1062  float Area;
1063  int i;
1064  Area = If_CutLutArea(p, pCut);
1065  If_CutForEachLeaf( p, pCut, pLeaf, i )
1066  {
1067  assert( pLeaf->nRefs >= 0 );
1068  if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) )
1069  continue;
1070  Area += If_CutAreaRef( p, If_ObjCutBest(pLeaf) );
1071  }
1072  return Area;
1073 }
static float If_CutLutArea(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:428
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int nRefs
Definition: if.h:318
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
#define assert(ex)
Definition: util_old.h:213
float If_CutAreaRefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1109 of file ifCut.c.

1110 {
1111  float aResult, aResult2;
1112  if ( pCut->nLeaves < 2 )
1113  return 0;
1114  aResult2 = If_CutAreaDeref( p, pCut );
1115  aResult = If_CutAreaRef( p, pCut );
1116  assert( aResult > aResult2 - p->fEpsilon );
1117  assert( aResult < aResult2 + p->fEpsilon );
1118  return aResult;
1119 }
unsigned nLeaves
Definition: if.h:289
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float fEpsilon
Definition: if.h:195
#define assert(ex)
Definition: util_old.h:213
float If_CutAverageRefs ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Average number of references of the leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 1010 of file ifCut.c.

1011 {
1012  If_Obj_t * pLeaf;
1013  int nRefsTotal, i;
1014  nRefsTotal = 0;
1015  If_CutForEachLeaf( p, pCut, pLeaf, i )
1016  nRefsTotal += pLeaf->nRefs;
1017  return ((float)nRefsTotal)/pCut->nLeaves;
1018 }
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
int If_CutCheck ( If_Cut_t pCut)

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

Synopsis [Checks correctness of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 826 of file ifCut.c.

827 {
828  int i;
829  assert( pCut->nLeaves <= pCut->nLimit );
830  if ( pCut->nLeaves < 2 )
831  return 1;
832  for ( i = 1; i < (int)pCut->nLeaves; i++ )
833  {
834  if ( pCut->pLeaves[i-1] >= pCut->pLeaves[i] )
835  {
836  Abc_Print( -1, "If_CutCheck(): Cut has wrong ordering of inputs.\n" );
837  return 0;
838  }
839  assert( pCut->pLeaves[i-1] < pCut->pLeaves[i] );
840  }
841  return 1;
842 }
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pLeaves[0]
Definition: if.h:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define assert(ex)
Definition: util_old.h:213
int If_CutComputeTruth ( If_Man_t p,
If_Cut_t pCut,
If_Cut_t pCut0,
If_Cut_t pCut1,
int  fCompl0,
int  fCompl1 
)

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

Synopsis [Truth table computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file ifTruth.c.

99 {
100  int fCompl, truthId, nLeavesNew, PrevSize, RetValue = 0;
101  word * pTruth0s = Vec_MemReadEntry( p->vTtMem[pCut0->nLeaves], Abc_Lit2Var(pCut0->iCutFunc) );
102  word * pTruth1s = Vec_MemReadEntry( p->vTtMem[pCut1->nLeaves], Abc_Lit2Var(pCut1->iCutFunc) );
103  word * pTruth0 = (word *)p->puTemp[0];
104  word * pTruth1 = (word *)p->puTemp[1];
105  word * pTruth = (word *)p->puTemp[2];
106  Abc_TtCopy( pTruth0, pTruth0s, p->nTruth6Words[pCut0->nLeaves], fCompl0 ^ pCut0->fCompl ^ Abc_LitIsCompl(pCut0->iCutFunc) );
107  Abc_TtCopy( pTruth1, pTruth1s, p->nTruth6Words[pCut1->nLeaves], fCompl1 ^ pCut1->fCompl ^ Abc_LitIsCompl(pCut1->iCutFunc) );
108  Abc_TtStretch6( pTruth0, pCut0->nLeaves, pCut->nLeaves );
109  Abc_TtStretch6( pTruth1, pCut1->nLeaves, pCut->nLeaves );
110  Abc_TtExpand( pTruth0, pCut->nLeaves, pCut0->pLeaves, pCut0->nLeaves, pCut->pLeaves, pCut->nLeaves );
111  Abc_TtExpand( pTruth1, pCut->nLeaves, pCut1->pLeaves, pCut1->nLeaves, pCut->pLeaves, pCut->nLeaves );
112  fCompl = (pTruth0[0] & pTruth1[0] & 1);
113  Abc_TtAnd( pTruth, pTruth0, pTruth1, p->nTruth6Words[pCut->nLeaves], fCompl );
114  if ( p->pPars->fCutMin && (pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || pCut0->nLeaves == 0 || pCut1->nLeaves == 0) )
115  {
116  nLeavesNew = Abc_TtMinBase( pTruth, pCut->pLeaves, pCut->nLeaves, pCut->nLeaves );
117  if ( nLeavesNew < If_CutLeaveNum(pCut) )
118  {
119  pCut->nLeaves = nLeavesNew;
120  pCut->uSign = If_ObjCutSignCompute( pCut );
121  RetValue = 1;
122  }
123  }
124  PrevSize = Vec_MemEntryNum( p->vTtMem[pCut->nLeaves] );
125  truthId = Vec_MemHashInsert( p->vTtMem[pCut->nLeaves], pTruth );
126  pCut->iCutFunc = Abc_Var2Lit( truthId, fCompl );
127  assert( (pTruth[0] & 1) == 0 );
128 #ifdef IF_TRY_NEW
129  {
130  word pCopy[1024];
131  char pCanonPerm[16];
132  memcpy( pCopy, If_CutTruthW(pCut), sizeof(word) * p->nTruth6Words[pCut->nLeaves] );
133  Abc_TtCanonicize( pCopy, pCut->nLeaves, pCanonPerm );
134  }
135 #endif
136  if ( p->vTtIsops[pCut->nLeaves] && PrevSize != Vec_MemEntryNum(p->vTtMem[pCut->nLeaves]) )
137  {
138  Vec_Int_t * vLevel = Vec_WecPushLevel( p->vTtIsops[pCut->nLeaves] );
139  fCompl = Kit_TruthIsop( (unsigned *)pTruth, pCut->nLeaves, p->vCover, 1 );
140  if ( fCompl >= 0 )
141  {
142  Vec_IntGrow( vLevel, Vec_IntSize(p->vCover) );
143  Vec_IntAppend( vLevel, p->vCover );
144  if ( fCompl )
145  vLevel->nCap ^= (1<<16); // hack to remember complemented attribute
146  }
147  assert( Vec_WecSize(p->vTtIsops[pCut->nLeaves]) == Vec_MemEntryNum(p->vTtMem[pCut->nLeaves]) );
148  }
149  return RetValue;
150 }
int nTruth6Words[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:226
unsigned nLeaves
Definition: if.h:289
static int Abc_TtMinBase(word *pTruth, int *pVars, int nVars, int nVarsAll)
Definition: utilTruth.h:1395
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:245
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:244
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
char * memcpy()
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
int pLeaves[0]
Definition: if.h:290
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static unsigned If_ObjCutSignCompute(If_Cut_t *p)
Definition: if.h:403
unsigned * puTemp[4]
Definition: if.h:203
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TtStretch6(word *pInOut, int nVarS, int nVarB)
Definition: utilTruth.h:693
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
Vec_Int_t * vCover
Definition: if.h:214
If_Par_t * pPars
Definition: if.h:184
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Abc_TtExpand(word *pTruth0, int nVars, int *pCut0, int nCutSize0, int *pCut, int nCutSize)
Definition: utilTruth.h:1360
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
unsigned Abc_TtCanonicize(word *pTruth, int nVars, char *pCanonPerm)
FUNCTION DECLARATIONS ///.
Definition: dauCanon.c:895
unsigned uSign
Definition: if.h:283
int fCutMin
Definition: if.h:120
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
#define assert(ex)
Definition: util_old.h:213
unsigned fCompl
Definition: if.h:285
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
static void Abc_TtAnd(word *pOut, word *pIn1, word *pIn2, int nWords, int fCompl)
Definition: utilTruth.h:231
int iCutFunc
Definition: if.h:281
int If_CutComputeTruthPerm ( If_Man_t p,
If_Cut_t pCut,
If_Cut_t pCut0,
If_Cut_t pCut1,
int  fCompl0,
int  fCompl1 
)

Definition at line 263 of file ifTruth.c.

264 {
265  abctime clk = 0;
266  int i, Num, nEntriesOld, RetValue;
267  if ( pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || iCutFunc0 < 2 || iCutFunc1 < 2 )
268  {
269 if ( p->pPars->fVerbose )
270 clk = Abc_Clock();
271  RetValue = If_CutComputeTruthPerm_int( p, pCut, pCut0, pCut1, iCutFunc0, iCutFunc1 );
272 if ( p->pPars->fVerbose )
273 p->timeCache[0] += Abc_Clock() - clk;
274  return RetValue;
275  }
276  assert( pCut0->nLeaves + pCut1->nLeaves == pCut->nLeaves );
277  nEntriesOld = Hash_IntManEntryNum(p->vPairHash);
278  Num = Hash_Int2ManInsert( p->vPairHash, (iCutFunc0 << 5)|pCut0->nLeaves, (iCutFunc1 << 5)|pCut1->nLeaves, -1 );
279  assert( Num > 0 );
280  if ( nEntriesOld == Hash_IntManEntryNum(p->vPairHash) )
281  {
282  char * pCanonPerm;
283  int v, pPerm[IF_MAX_LUTSIZE];
284  pCut->iCutFunc = Vec_IntEntry( p->vPairRes, Num );
285  // move complements from the fanin cuts
286  for ( v = 0; v < (int)pCut->nLeaves; v++ )
287  if ( v < (int)pCut0->nLeaves )
288  pCut->pLeaves[v] = Abc_Var2Lit( pCut->pLeaves[v], If_CutLeafBit(pCut0, v) );
289  else
290  pCut->pLeaves[v] = Abc_Var2Lit( pCut->pLeaves[v], If_CutLeafBit(pCut1, v-(int)pCut0->nLeaves) );
291  // reorder the cut
292  pCanonPerm = Vec_StrEntryP( p->vPairPerms, Num * pCut->nLimit );
293  for ( v = 0; v < (int)pCut->nLeaves; v++ )
294  pPerm[v] = Abc_LitNotCond( pCut->pLeaves[Abc_Lit2Var((int)pCanonPerm[v])], Abc_LitIsCompl((int)pCanonPerm[v]) );
295  // generate the result
296  pCut->uMaskFunc = 0;
297  for ( v = 0; v < (int)pCut->nLeaves; v++ )
298  {
299  pCut->pLeaves[v] = Abc_Lit2Var(pPerm[v]);
300  if ( Abc_LitIsCompl(pPerm[v]) )
301  pCut->uMaskFunc |= (1 << v);
302  }
303 // printf( "Found: %d(%d) %d(%d) -> %d(%d)\n", iCutFunc0, pCut0->nLeaves, iCutFunc1, pCut0->nLeaves, pCut->iCutFunc, pCut->nLeaves );
304  p->nCacheHits++;
305 //p->timeCache[1] += Abc_Clock() - clk;
306  return 0;
307  }
308 if ( p->pPars->fVerbose )
309 clk = Abc_Clock();
310  p->nCacheMisses++;
311  RetValue = If_CutComputeTruthPerm_int( p, pCut, pCut0, pCut1, iCutFunc0, iCutFunc1 );
312  assert( RetValue == 0 );
313 // printf( "Added: %d(%d) %d(%d) -> %d(%d)\n", iCutFunc0, pCut0->nLeaves, iCutFunc1, pCut0->nLeaves, pCut->iCutFunc, pCut->nLeaves );
314  // save the result
315  assert( Num == Vec_IntSize(p->vPairRes) );
316  Vec_IntPush( p->vPairRes, pCut->iCutFunc );
317  // save the permutation
318  assert( Num * (int)pCut->nLimit == Vec_StrSize(p->vPairPerms) );
319  for ( i = 0; i < (int)pCut->nLeaves; i++ )
320  Vec_StrPush( p->vPairPerms, (char)Abc_Var2Lit((int)p->pCanonPerm[i], ((p->uCanonPhase>>i)&1)) );
321  for ( i = (int)pCut0->nLeaves + (int)pCut1->nLeaves; i < (int)pCut->nLimit; i++ )
322  Vec_StrPush( p->vPairPerms, (char)-1 );
323 if ( p->pPars->fVerbose )
324 p->timeCache[2] += Abc_Clock() - clk;
325  return 0;
326 }
unsigned nLeaves
Definition: if.h:289
static int Hash_IntManEntryNum(Hash_IntMan_t *p)
Definition: vecHash.h:101
unsigned nLimit
Definition: if.h:288
int fVerbose
Definition: if.h:140
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Hash_IntMan_t * vPairHash
Definition: if.h:250
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int nCacheMisses
Definition: if.h:256
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
int pLeaves[0]
Definition: if.h:290
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
int If_CutComputeTruthPerm_int(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int iCutFunc0, int iCutFunc1)
Definition: ifTruth.c:163
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int pPerm[13719]
Definition: rwrTemp.c:32
static int Hash_Int2ManInsert(Hash_IntMan_t *p, int iData0, int iData1, int iData2)
Definition: vecHash.h:144
abctime timeCache[6]
Definition: if.h:257
int nCacheHits
Definition: if.h:255
Vec_Int_t * vPairRes
Definition: if.h:251
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
static int If_CutLeafBit(If_Cut_t *pCut, int i)
Definition: if.h:396
If_Par_t * pPars
Definition: if.h:184
int uMaskFunc
Definition: if.h:282
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
char pCanonPerm[IF_MAX_LUTSIZE]
Definition: if.h:253
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int iCutFunc
Definition: if.h:281
Vec_Str_t * vPairPerms
Definition: if.h:252
static char * Vec_StrEntryP(Vec_Str_t *p, int i)
Definition: vecStr.h:353
unsigned uCanonPhase
Definition: if.h:254
void If_CutCopy ( If_Man_t p,
If_Cut_t pDst,
If_Cut_t pSrc 
)
inlinestatic

Definition at line 398 of file if.h.

398 { memcpy( pDst, pSrc, p->nCutBytes ); }
char * memcpy()
int nCutBytes
Definition: if.h:229
static void* If_CutData ( If_Cut_t pCut)
inlinestatic

Definition at line 411 of file if.h.

411 { return *(void **)pCut; }
static int If_CutDataInt ( If_Cut_t pCut)
inlinestatic

Definition at line 414 of file if.h.

414 { return *(int *)pCut; }
float If_CutDelay ( If_Man_t p,
If_Obj_t pObj,
If_Cut_t pCut 
)

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

Synopsis [Computes delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file ifTime.c.

92 {
93  static int pPinPerm[IF_MAX_LUTSIZE];
94  static float pPinDelays[IF_MAX_LUTSIZE];
95  char * pPerm = If_CutPerm( pCut );
96  If_Obj_t * pLeaf;
97  float Delay, DelayCur;
98  float * pLutDelays;
99  int i, Shift, Pin2PinDelay;//, iLeaf;
100  Delay = -IF_FLOAT_LARGE;
101  if ( p->pPars->pLutLib )
102  {
103  assert( !p->pPars->fLiftLeaves );
104  pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
105  if ( p->pPars->pLutLib->fVarPinDelays )
106  {
107  // compute the delay using sorted pins
108  If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
109  for ( i = 0; i < (int)pCut->nLeaves; i++ )
110  {
111  DelayCur = pPinDelays[pPinPerm[i]] + pLutDelays[i];
112  Delay = IF_MAX( Delay, DelayCur );
113  }
114  }
115  else
116  {
117  If_CutForEachLeaf( p, pCut, pLeaf, i )
118  {
119  DelayCur = If_ObjCutBest(pLeaf)->Delay + pLutDelays[0];
120  Delay = IF_MAX( Delay, DelayCur );
121  }
122  }
123  }
124  else
125  {
126  if ( pCut->fUser )
127  {
128  assert( !p->pPars->fLiftLeaves );
129  If_CutForEachLeaf( p, pCut, pLeaf, i )
130  {
131  Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
132  DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)Pin2PinDelay;
133  Delay = IF_MAX( Delay, DelayCur );
134  }
135  }
136  else
137  {
138  if ( p->pPars->fLiftLeaves )
139  {
140  If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )
141  {
142  DelayCur = If_ObjCutBest(pLeaf)->Delay - Shift * p->Period;
143  Delay = IF_MAX( Delay, DelayCur + 1.0 );
144  }
145  }
146  else
147  {
148  If_CutForEachLeaf( p, pCut, pLeaf, i )
149  {
150  DelayCur = If_ObjCutBest(pLeaf)->Delay + 1.0;
151  Delay = IF_MAX( Delay, DelayCur );
152  }
153  }
154  }
155  }
156  return Delay;
157 }
#define IF_MAX(a, b)
Definition: if.h:437
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
#define IF_BIG_CHAR
Definition: if.h:60
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
unsigned fUser
Definition: if.h:286
#define If_CutForEachLeafSeq(p, pCut, pLeaf, Shift, i)
Definition: if.h:481
int fVarPinDelays
Definition: if.h:174
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
static int pPerm[13719]
Definition: rwrTemp.c:32
#define IF_FLOAT_LARGE
Definition: if.h:440
If_Par_t * pPars
Definition: if.h:184
int Period
Definition: if.h:224
ABC_NAMESPACE_IMPL_START void If_CutSortInputPins(If_Man_t *p, If_Cut_t *pCut, int *pPinPerm, float *pPinDelays)
DECLARATIONS ///.
Definition: ifTime.c:44
#define assert(ex)
Definition: util_old.h:213
int fLiftLeaves
Definition: if.h:156
float Delay
Definition: if.h:280
If_LibLut_t * pLutLib
Definition: if.h:160
float If_CutDelayLutStruct ( If_Man_t p,
If_Cut_t pCut,
char *  pStr,
float  WireDelay 
)

Definition at line 2103 of file ifDec16.c.

2104 {
2105  float Delays[CLU_VAR_MAX+2];
2106  int fUsed[CLU_VAR_MAX+2] = {0};
2107  If_Obj_t * pLeaf;
2108  If_Grp_t G1 = {0}, G2 = {0}, G3 = {0};
2109  int nLeaves = If_CutLeaveNum(pCut);
2110  int i, nLutLeaf, nLutRoot;
2111  // mark the cut as user cut
2112 // pCut->fUser = 1;
2113  // quit if parameters are wrong
2114  if ( strlen(pStr) != 2 )
2115  {
2116  printf( "Wrong LUT struct (%s)\n", pStr );
2117  return ABC_INFINITY;
2118  }
2119  nLutLeaf = pStr[0] - '0';
2120  if ( nLutLeaf < 3 || nLutLeaf > 6 )
2121  {
2122  printf( "Leaf size (%d) should belong to {3,4,5,6}.\n", nLutLeaf );
2123  return ABC_INFINITY;
2124  }
2125  nLutRoot = pStr[1] - '0';
2126  if ( nLutRoot < 3 || nLutRoot > 6 )
2127  {
2128  printf( "Root size (%d) should belong to {3,4,5,6}.\n", nLutRoot );
2129  return ABC_INFINITY;
2130  }
2131  if ( nLeaves > nLutLeaf + nLutRoot - 1 )
2132  {
2133  printf( "The cut size (%d) is too large for the LUT structure %d%d.\n", If_CutLeaveNum(pCut), nLutLeaf, nLutRoot );
2134  return ABC_INFINITY;
2135  }
2136 
2137  // remember the delays
2138  If_CutForEachLeaf( p, pCut, pLeaf, i )
2139  Delays[i] = If_ObjCutBest(pLeaf)->Delay;
2140 
2141  // consider easy case
2142  if ( nLeaves <= Abc_MaxInt( nLutLeaf, nLutRoot ) )
2143  {
2144  char * pPerm = If_CutPerm( pCut );
2145  assert( nLeaves <= 6 );
2146  for ( i = 0; i < nLeaves; i++ )
2147  {
2148  pPerm[i] = 1;
2149  G1.pVars[i] = i;
2150  }
2151  G1.nVars = nLeaves;
2152  return 1.0 + If_CluDelayMax( &G1, Delays );
2153  }
2154 
2155  // derive the first group
2156  G1 = If_CluCheck( p, If_CutTruthW(p, pCut), nLeaves, 0, 0, nLutLeaf, nLutRoot, NULL, NULL, NULL, NULL, 1 );
2157  if ( G1.nVars == 0 )
2158  return ABC_INFINITY;
2159 
2160  // compute the delay
2161  Delays[nLeaves] = If_CluDelayMax( &G1, Delays ) + ((WireDelay == 0.0)?1.0:WireDelay);
2162  if ( G2.nVars )
2163  Delays[nLeaves+1] = If_CluDelayMax( &G2, Delays ) + ((WireDelay == 0.0)?1.0:WireDelay);
2164 
2165  // mark used groups
2166  for ( i = 0; i < G1.nVars; i++ )
2167  fUsed[(int)G1.pVars[i]] = 1;
2168  for ( i = 0; i < G2.nVars; i++ )
2169  fUsed[(int)G2.pVars[i]] = 1;
2170  // mark unused groups
2171  assert( G1.nMyu >= 2 && G1.nMyu <= 4 );
2172  if ( G1.nMyu > 2 )
2173  fUsed[(int)G1.pVars[G1.nVars-1]] = 0;
2174  assert( !G2.nVars || (G2.nMyu >= 2 && G2.nMyu <= 4) );
2175  if ( G2.nMyu > 2 )
2176  fUsed[(int)G2.pVars[G2.nVars-1]] = 0;
2177 
2178  // create remaining group
2179  assert( G3.nVars == 0 );
2180  for ( i = 0; i < nLeaves; i++ )
2181  if ( !fUsed[i] )
2182  G3.pVars[(int)G3.nVars++] = i;
2183  G3.pVars[(int)G3.nVars++] = nLeaves;
2184  if ( G2.nVars )
2185  G3.pVars[(int)G3.nVars++] = nLeaves+1;
2186  assert( G1.nVars + G2.nVars + G3.nVars == nLeaves +
2187  (G1.nVars > 0) + (G2.nVars > 0) + (G1.nMyu > 2) + (G2.nMyu > 2) );
2188  // what if both non-disjoint vars are the same???
2189 
2190  pCut->Cost = 2 + (G2.nVars > 0);
2191  return 1.0 + If_CluDelayMax( &G3, Delays );
2192 }
Definition: if.h:303
If_Grp_t If_CluCheck(If_Man_t *p, word *pTruth0, int nVars, int iVarStart, int iVarStop, int nLutLeaf, int nLutRoot, If_Grp_t *pR, word *pFunc0, word *pFunc1, word *pLeftOver, int fHashing)
Definition: ifDec16.c:1553
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
unsigned Cost
Definition: if.h:284
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
char nMyu
Definition: ifDec16.c:41
#define CLU_VAR_MAX
DECLARATIONS ///.
Definition: ifDec16.c:31
if(last==0)
Definition: sparse_int.h:34
float If_CluDelayMax(If_Grp_t *g, float *pDelays)
Definition: ifDec16.c:2093
static int pPerm[13719]
Definition: rwrTemp.c:32
char pVars[CLU_VAR_MAX]
Definition: ifDec16.c:42
char nVars
Definition: ifDec16.c:40
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
int strlen()
int If_CutDelaySop ( If_Man_t p,
If_Cut_t pCut 
)

Definition at line 64 of file ifDelay.c.

65 {
66  char * pPerm = If_CutPerm( pCut );
67  // delay is calculated using 1+log2(NumFanins)
68  static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
69  Vec_Int_t * vCover;
70  If_Obj_t * pLeaf;
71  int i, nLitMax, Delay, DelayMax;
72  // mark cut as a user cut
73  pCut->fUser = 1;
74  if ( pCut->nLeaves == 0 )
75  return 0;
76  if ( pCut->nLeaves == 1 )
77  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
78  vCover = Vec_WecEntry( p->vTtIsops[pCut->nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
79  if ( Vec_IntSize(vCover) == 0 )
80  return -1;
81  // mark the output as complemented
82 // vAnds = If_CutDelaySopAnds( p, pCut, vCover, RetValue ^ pCut->fCompl );
83  if ( Vec_IntSize(vCover) > p->pPars->nGateSize )
84  return -1;
85  // set the area cost
86  assert( If_CutLeaveNum(pCut) >= 0 && If_CutLeaveNum(pCut) <= 16 );
87  // compute the gate delay
88  nLitMax = If_CutMaxCubeSize( vCover, If_CutLeaveNum(pCut) );
89  if ( Vec_IntSize(vCover) < 2 )
90  {
91  pCut->Cost = Vec_IntSize(vCover);
92  Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + 0.5);
93  DelayMax = 0;
94  If_CutForEachLeaf( p, pCut, pLeaf, i )
95  DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pPerm[i] = (char)Delay) );
96  }
97  else
98  {
99  pCut->Cost = Vec_IntSize(vCover) + 1;
100  Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + GateDelays[nLitMax] + 0.5);
101  DelayMax = 0;
102  If_CutForEachLeaf( p, pCut, pLeaf, i )
103  DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pPerm[i] = (char)Delay) );
104  }
105  return DelayMax;
106 }
unsigned nLeaves
Definition: if.h:289
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:245
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
unsigned fUser
Definition: if.h:286
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int nGateSize
Definition: if.h:107
unsigned Cost
Definition: if.h:284
static int If_CutTruthLit(If_Cut_t *pCut)
Definition: if.h:417
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
else
Definition: sparse_int.h:55
static int pPerm[13719]
Definition: rwrTemp.c:32
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
If_Par_t * pPars
Definition: if.h:184
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static int If_CutMaxCubeSize(Vec_Int_t *vCover, int nVars)
FUNCTION DEFINITIONS ///.
Definition: ifDelay.c:48
float Delay
Definition: if.h:280
int If_CutDsdBalanceEval ( If_Man_t p,
If_Cut_t pCut,
Vec_Int_t vAig 
)

Definition at line 2288 of file ifDsd.c.

2289 {
2290  int fUseCofs = 0;
2291  pCut->fUser = 1;
2292  if ( vAig )
2293  Vec_IntClear( vAig );
2294  if ( pCut->nLeaves == 0 ) // const
2295  {
2296  assert( Abc_Lit2Var(If_CutDsdLit(p, pCut)) == 0 );
2297  if ( vAig )
2298  Vec_IntPush( vAig, Abc_LitIsCompl(If_CutDsdLit(p, pCut)) );
2299  pCut->Cost = 0;
2300  return 0;
2301  }
2302  if ( pCut->nLeaves == 1 ) // variable
2303  {
2304  assert( Abc_Lit2Var(If_CutDsdLit(p, pCut)) == 1 );
2305  if ( vAig )
2306  Vec_IntPush( vAig, 0 );
2307  if ( vAig )
2308  Vec_IntPush( vAig, Abc_LitIsCompl(If_CutDsdLit(p, pCut)) );
2309  pCut->Cost = 0;
2310  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
2311  }
2312  else
2313  {
2314  int fVerbose = 0;
2315  int i, pTimes[IF_MAX_FUNC_LUTSIZE];
2316  int Delay, Area = 0;
2317  char * pPermLits = If_CutDsdPerm(p, pCut);
2318  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
2319  pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
2320  Delay = If_CutDsdBalanceEvalInt( p->pIfDsdMan, Abc_LitNotCond(If_CutDsdLit(p, pCut), pCut->fCompl), pTimes, vAig, &Area, If_CutDsdPerm(p, pCut) );
2321  pCut->Cost = Area;
2322  // try cofactoring
2323  if ( fUseCofs )
2324  {
2325  // count how many times the max one appears
2326  int iMax = 0, nCountMax = 1;
2327  for ( i = 1; i < If_CutLeaveNum(pCut); i++ )
2328  if ( pTimes[i] > pTimes[iMax] )
2329  iMax = i, nCountMax = 1;
2330  else if ( pTimes[i] == pTimes[iMax] )
2331  nCountMax++;
2332  // decide when to try the decomposition
2333  if ( nCountMax == 1 && pTimes[iMax] + 2 < Delay && If_DsdManCheckNonTriv( p->pIfDsdMan, Abc_Lit2Var(If_CutDsdLit(p, pCut)),
2334  If_CutLeaveNum(pCut), If_CutDsdPermLitMax(pPermLits, If_CutLeaveNum(pCut), iMax)) )
2335  {
2336 // fVerbose = 1;
2337  Delay = pTimes[iMax] + 2;
2338  }
2339  }
2340  // report the result
2341  if ( fVerbose )
2342  {
2343 /*
2344  int Max = 0, Two = 0;
2345  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
2346  Max = Abc_MaxInt( Max, pTimes[i] );
2347  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
2348  if ( pTimes[i] != Max )
2349  Two = Abc_MaxInt( Two, pTimes[i] );
2350  if ( Two + 2 < Max && Max + 3 < Delay )
2351 */
2352  {
2353  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
2354  printf( "%3d ", pTimes[Abc_Lit2Var(pPermLits[i])] );
2355  for ( ; i < p->pPars->nLutSize; i++ )
2356  printf( " " );
2357  printf( "-> %3d ", Delay );
2358  If_DsdManPrintOne( stdout, p->pIfDsdMan, Abc_Lit2Var(If_CutDsdLit(p, pCut)), NULL, 0 );
2359  printf( "\n" );
2360  }
2361  }
2362  return Delay;
2363  }
2364 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
unsigned nLeaves
Definition: if.h:289
int nLutSize
Definition: if.h:103
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
void If_DsdManPrintOne(FILE *pFile, If_DsdMan_t *p, int iObjId, unsigned char *pPermLits, int fNewLine)
Definition: ifDsd.c:492
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
unsigned fUser
Definition: if.h:286
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
int If_CutDsdBalanceEvalInt(If_DsdMan_t *p, int iDsd, int *pTimes, Vec_Int_t *vAig, int *pArea, char *pPermLits)
Definition: ifDsd.c:2274
unsigned Cost
Definition: if.h:284
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int If_CutDsdPermLitMax(char *pPermLits, int nVars, int iVar)
Definition: ifDsd.c:2186
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
If_Par_t * pPars
Definition: if.h:184
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
int If_DsdManCheckNonTriv(If_DsdMan_t *p, int Id, int nVars, int iVarMax)
Definition: ifDsd.c:802
unsigned fCompl
Definition: if.h:285
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float Delay
Definition: if.h:280
int If_CutDsdBalancePinDelays ( If_Man_t p,
If_Cut_t pCut,
char *  pPerm 
)

Definition at line 2152 of file ifDsd.c.

2153 {
2154  if ( pCut->nLeaves == 0 ) // const
2155  return 0;
2156  if ( pCut->nLeaves == 1 ) // variable
2157  {
2158  pPerm[0] = 0;
2159  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
2160  }
2161  else
2162  {
2163  word Result = 0;
2164  int i, Delay, nSupp = 0, pTimes[IF_MAX_FUNC_LUTSIZE];
2165  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
2166  pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
2167  Delay = If_CutDsdBalancePinDelays_rec( p->pIfDsdMan, Abc_Lit2Var(If_CutDsdLit(p, pCut)), pTimes, &Result, &nSupp, If_CutLeaveNum(pCut), If_CutDsdPerm(p, pCut) );
2168  assert( nSupp == If_CutLeaveNum(pCut) );
2169  If_CutPinDelayTranslate( Result, If_CutLeaveNum(pCut), pPerm );
2170  return Delay;
2171  }
2172 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
unsigned nLeaves
Definition: if.h:289
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static int pPerm[13719]
Definition: rwrTemp.c:32
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
int If_CutDsdBalancePinDelays_rec(If_DsdMan_t *p, int Id, int *pTimes, word *pRes, int *pnSupp, int nSuppAll, char *pPermLits)
Definition: ifDsd.c:2104
static void If_CutPinDelayTranslate(word D, int nVars, char *pPerm)
Definition: ifCount.h:181
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float Delay
Definition: if.h:280
static int If_CutDsdIsCompl ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 425 of file if.h.

425 { return Abc_LitIsCompl( If_CutDsdLit(p, pCut) ); }
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
static int If_CutDsdLit ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 424 of file if.h.

424 { return Abc_Lit2LitL( Vec_IntArray(p->vTtDsds[pCut->nLeaves]), If_CutTruthLit(pCut) ); }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
unsigned nLeaves
Definition: if.h:289
static int Abc_Lit2LitL(int *pMap, int Lit)
Definition: abc_global.h:270
static int If_CutTruthLit(If_Cut_t *pCut)
Definition: if.h:417
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:246
static char* If_CutDsdPerm ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 426 of file if.h.

426 { return Vec_StrEntryP( p->vTtPerms[pCut->nLeaves], Abc_Lit2Var(pCut->iCutFunc) * Abc_MaxInt(6, pCut->nLeaves) ); }
unsigned nLeaves
Definition: if.h:289
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:247
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int iCutFunc
Definition: if.h:281
static char * Vec_StrEntryP(Vec_Str_t *p, int i)
Definition: vecStr.h:353
float If_CutEdgeDeref ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1133 of file ifCut.c.

1134 {
1135  If_Obj_t * pLeaf;
1136  float Edge;
1137  int i;
1138  Edge = pCut->nLeaves;
1139  If_CutForEachLeaf( p, pCut, pLeaf, i )
1140  {
1141  assert( pLeaf->nRefs > 0 );
1142  if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) )
1143  continue;
1144  Edge += If_CutEdgeDeref( p, If_ObjCutBest(pLeaf) );
1145  }
1146  return Edge;
1147 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int nRefs
Definition: if.h:318
float If_CutEdgeDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1133
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeDerefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes edge of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1187 of file ifCut.c.

1188 {
1189  float aResult, aResult2;
1190  if ( pCut->nLeaves < 2 )
1191  return pCut->nLeaves;
1192  aResult2 = If_CutEdgeRef( p, pCut );
1193  aResult = If_CutEdgeDeref( p, pCut );
1194  assert( aResult > aResult2 - p->fEpsilon );
1195  assert( aResult < aResult2 + p->fEpsilon );
1196  return aResult;
1197 }
unsigned nLeaves
Definition: if.h:289
float If_CutEdgeRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1160
float fEpsilon
Definition: if.h:195
float If_CutEdgeDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1133
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeFlow ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area flow.]

Description []

SideEffects []

SeeAlso []

Definition at line 949 of file ifCut.c.

950 {
951  If_Obj_t * pLeaf;
952  float Flow;
953  int i;
954  Flow = pCut->nLeaves;
955  If_CutForEachLeaf( p, pCut, pLeaf, i )
956  {
957  if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
958  Flow += If_ObjCutBest(pLeaf)->Edge;
959  else
960  {
961  assert( pLeaf->EstRefs > p->fEpsilon );
962  Flow += If_ObjCutBest(pLeaf)->Edge / pLeaf->EstRefs;
963  }
964  }
965  return Flow;
966 }
unsigned nLeaves
Definition: if.h:289
float Edge
Definition: if.h:278
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int nRefs
Definition: if.h:318
float fEpsilon
Definition: if.h:195
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeRef ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1160 of file ifCut.c.

1161 {
1162  If_Obj_t * pLeaf;
1163  float Edge;
1164  int i;
1165  Edge = pCut->nLeaves;
1166  If_CutForEachLeaf( p, pCut, pLeaf, i )
1167  {
1168  assert( pLeaf->nRefs >= 0 );
1169  if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) )
1170  continue;
1171  Edge += If_CutEdgeRef( p, If_ObjCutBest(pLeaf) );
1172  }
1173  return Edge;
1174 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
float If_CutEdgeRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1160
int nRefs
Definition: if.h:318
#define assert(ex)
Definition: util_old.h:213
float If_CutEdgeRefed ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1210 of file ifCut.c.

1211 {
1212  float aResult, aResult2;
1213  if ( pCut->nLeaves < 2 )
1214  return pCut->nLeaves;
1215  aResult2 = If_CutEdgeDeref( p, pCut );
1216  aResult = If_CutEdgeRef( p, pCut );
1217  assert( aResult > aResult2 - p->fEpsilon );
1218  assert( aResult < aResult2 + p->fEpsilon );
1219  return aResult;
1220 }
unsigned nLeaves
Definition: if.h:289
float If_CutEdgeRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1160
float fEpsilon
Definition: if.h:195
float If_CutEdgeDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1133
#define assert(ex)
Definition: util_old.h:213
int If_CutFilter ( If_Set_t pCutSet,
If_Cut_t pCut,
int  fSaveCut0 
)

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

Synopsis [Returns 1 if the cut is contained.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file ifCut.c.

147 {
148  If_Cut_t * pTemp;
149  int i, k;
150  assert( pCutSet->ppCuts[pCutSet->nCuts] == pCut );
151  for ( i = 0; i < pCutSet->nCuts; i++ )
152  {
153  pTemp = pCutSet->ppCuts[i];
154  if ( pTemp->nLeaves > pCut->nLeaves )
155  {
156  // do not fiter the first cut
157  if ( i == 0 && ((pCutSet->nCuts > 1 && pCutSet->ppCuts[1]->fUseless) || (fSaveCut0 && pCutSet->nCuts == 1)) )
158  continue;
159  // skip the non-contained cuts
160  if ( (pTemp->uSign & pCut->uSign) != pCut->uSign )
161  continue;
162  // check containment seriously
163  if ( If_CutCheckDominance( pCut, pTemp ) )
164  {
165 // p->ppCuts[i] = p->ppCuts[p->nCuts-1];
166 // p->ppCuts[p->nCuts-1] = pTemp;
167 // p->nCuts--;
168 // i--;
169  // remove contained cut
170  for ( k = i; k < pCutSet->nCuts; k++ )
171  pCutSet->ppCuts[k] = pCutSet->ppCuts[k+1];
172  pCutSet->ppCuts[pCutSet->nCuts] = pTemp;
173  pCutSet->nCuts--;
174  i--;
175  }
176  }
177  else
178  {
179  // skip the non-contained cuts
180  if ( (pTemp->uSign & pCut->uSign) != pTemp->uSign )
181  continue;
182  // check containment seriously
183  if ( If_CutCheckDominance( pTemp, pCut ) )
184  return 1;
185  }
186  }
187  return 0;
188 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
unsigned fUseless
Definition: if.h:287
short nCuts
Definition: if.h:297
unsigned uSign
Definition: if.h:283
static int If_CutCheckDominance(If_Cut_t *pDom, If_Cut_t *pCut)
Definition: ifCut.c:119
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
static If_Obj_t* If_CutLeaf ( If_Man_t p,
If_Cut_t pCut,
int  i 
)
inlinestatic

Definition at line 392 of file if.h.

392 { assert(i >= 0 && i < (int)pCut->nLeaves); return If_ManObj(p, pCut->pLeaves[i]); }
unsigned nLeaves
Definition: if.h:289
static If_Obj_t * If_ManObj(If_Man_t *p, int i)
Definition: if.h:370
int pLeaves[0]
Definition: if.h:290
#define assert(ex)
Definition: util_old.h:213
static int If_CutLeafBit ( If_Cut_t pCut,
int  i 
)
inlinestatic

Definition at line 396 of file if.h.

396 { return (pCut->uMaskFunc >> i) & 1; }
int uMaskFunc
Definition: if.h:282
static int If_CutLeaveNum ( If_Cut_t pCut)
inlinestatic

Definition at line 390 of file if.h.

390 { return pCut->nLeaves; }
unsigned nLeaves
Definition: if.h:289
static int* If_CutLeaves ( If_Cut_t pCut)
inlinestatic

Definition at line 391 of file if.h.

391 { return pCut->pLeaves; }
int pLeaves[0]
Definition: if.h:290
void If_CutLift ( If_Cut_t pCut)

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

Synopsis [Moves the cut over the latch.]

Description []

SideEffects []

SeeAlso []

Definition at line 897 of file ifCut.c.

898 {
899  unsigned i;
900  for ( i = 0; i < pCut->nLeaves; i++ )
901  {
902  assert( (pCut->pLeaves[i] & 255) < 255 );
903  pCut->pLeaves[i]++;
904  }
905 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
#define assert(ex)
Definition: util_old.h:213
static float If_CutLutArea ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 428 of file if.h.

428 { return pCut->fUser? (float)pCut->Cost : (p->pPars->pLutLib? p->pPars->pLutLib->pLutAreas[pCut->nLeaves] : (float)1.0); }
unsigned nLeaves
Definition: if.h:289
unsigned fUser
Definition: if.h:286
unsigned Cost
Definition: if.h:284
If_Par_t * pPars
Definition: if.h:184
float pLutAreas[IF_MAX_LUTSIZE+1]
Definition: if.h:175
If_LibLut_t * pLutLib
Definition: if.h:160
int If_CutLutBalanceEval ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Evaluate delay using SOP balancing.]

Description []

SideEffects []

SeeAlso []

Definition at line 369 of file ifDelay.c.

370 {
371  pCut->fUser = 1;
372  pCut->Cost = pCut->nLeaves > 1 ? 1 : 0;
373  pCut->uMaskFunc = 0;
374  if ( pCut->nLeaves == 0 ) // const
375  {
376  assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
377  return 0;
378  }
379  if ( pCut->nLeaves == 1 ) // variable
380  {
381  assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
382  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
383  }
384  else
385  {
386  char * pCutPerm = If_CutDsdPerm( p, pCut );
387  int LutSize = p->pPars->pLutStruct[0] - '0';
388  int i, pTimes[IF_MAX_FUNC_LUTSIZE];
389  int DelayMax = -1, nLeafMax = 0;
390  unsigned uLeafMask = 0;
391  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
392  {
393  pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, Abc_Lit2Var((int)pCutPerm[i])))->Delay;
394  if ( DelayMax < pTimes[i] )
395  DelayMax = pTimes[i], nLeafMax = 1, uLeafMask = (1 << (i << 1));
396  else if ( DelayMax == pTimes[i] )
397  nLeafMax++, uLeafMask |= (1 << (i << 1));
398  }
399  if ( If_CutLeaveNum(pCut) <= LutSize )
400  return DelayMax + 1;
401  pCut->Cost = 2;
402  if ( nLeafMax <= LutSize - 1 )
403  {
404  pCut->uMaskFunc = If_DsdManCheckXY( p->pIfDsdMan, If_CutDsdLit(p, pCut), LutSize, 1, uLeafMask, 0, 0 );
405  if ( pCut->uMaskFunc > 0 )
406  return DelayMax + 1;
407  }
408  pCut->uMaskFunc = If_DsdManCheckXY( p->pIfDsdMan, If_CutDsdLit(p, pCut), LutSize, 1, 0, 0, 0 );
409  if ( pCut->uMaskFunc == 0 )
410  return -1;
411  return DelayMax + 2;
412  }
413 }
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
unsigned nLeaves
Definition: if.h:289
unsigned If_DsdManCheckXY(If_DsdMan_t *p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose)
Definition: ifDsd.c:1986
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
char * pLutStruct
Definition: if.h:141
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
unsigned fUser
Definition: if.h:286
unsigned Cost
Definition: if.h:284
static int If_CutTruthLit(If_Cut_t *pCut)
Definition: if.h:417
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
If_Par_t * pPars
Definition: if.h:184
int uMaskFunc
Definition: if.h:282
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float Delay
Definition: if.h:280
int If_CutLutBalancePinDelays ( If_Man_t p,
If_Cut_t pCut,
char *  pPerm 
)

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

Synopsis [Evaluate delay using SOP balancing.]

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file ifDelay.c.

328 {
329  if ( pCut->nLeaves == 0 ) // const
330  return 0;
331  if ( pCut->nLeaves == 1 ) // variable
332  {
333  pPerm[0] = 0;
334  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
335  }
336  else
337  {
338  char * pCutPerm = If_CutDsdPerm( p, pCut );
339  int LutSize = p->pPars->pLutStruct[0] - '0';
340  int i, Delay, DelayMax = -1;
341  assert( (If_CutLeaveNum(pCut) > LutSize) == (pCut->uMaskFunc > 0) );
342  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
343  {
344  if ( If_CutLeaveNum(pCut) > LutSize && ((pCut->uMaskFunc >> (i << 1)) & 1) )
345  pPerm[Abc_Lit2Var((int)pCutPerm[i])] = 2;
346  else
347  pPerm[Abc_Lit2Var((int)pCutPerm[i])] = 1;
348  }
349  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
350  {
351  Delay = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
352  DelayMax = Abc_MaxInt( DelayMax, Delay + (int)pPerm[i] );
353  }
354  return DelayMax;
355  }
356 }
unsigned nLeaves
Definition: if.h:289
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
char * pLutStruct
Definition: if.h:141
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
static int pPerm[13719]
Definition: rwrTemp.c:32
If_Par_t * pPars
Definition: if.h:184
int uMaskFunc
Definition: if.h:282
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float Delay
Definition: if.h:280
static float If_CutLutDelay ( If_LibLut_t p,
int  Size,
int  iPin 
)
inlinestatic

Definition at line 429 of file if.h.

429 { return p ? (p->fVarPinDelays ? p->pLutDelays[Size][iPin] : p->pLutDelays[Size][0]) : 1.0; }
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
int If_CutMerge ( If_Man_t p,
If_Cut_t pCut0,
If_Cut_t pCut1,
If_Cut_t pCut 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 364 of file ifCut.c.

365 {
366  int nLutSize = pCut0->nLimit;
367  int nSize0 = pCut0->nLeaves;
368  int nSize1 = pCut1->nLeaves;
369  int * pC0 = pCut0->pLeaves;
370  int * pC1 = pCut1->pLeaves;
371  int * pC = pCut->pLeaves;
372  int i, k, c;
373  // compare two cuts with different numbers
374  c = nSize0;
375  for ( i = 0; i < nSize1; i++ )
376  {
377  for ( k = 0; k < nSize0; k++ )
378  if ( pC1[i] == pC0[k] )
379  break;
380  if ( k < nSize0 )
381  {
382  p->pPerm[1][i] = k;
383  continue;
384  }
385  if ( c == nLutSize )
386  return 0;
387  p->pPerm[1][i] = c;
388  pC[c++] = pC1[i];
389  }
390  for ( i = 0; i < nSize0; i++ )
391  pC[i] = pC0[i];
392  pCut->nLeaves = c;
393  pCut->uSign = pCut0->uSign | pCut1->uSign;
394  return 1;
395 }
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pPerm[3][IF_MAX_LUTSIZE]
Definition: if.h:209
int pLeaves[0]
Definition: if.h:290
unsigned uSign
Definition: if.h:283
int If_CutMergeOrdered ( If_Man_t p,
If_Cut_t pC0,
If_Cut_t pC1,
If_Cut_t pC 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 290 of file ifCut.c.

291 {
292  int nSizeC0 = pC0->nLeaves;
293  int nSizeC1 = pC1->nLeaves;
294  int nLimit = pC0->nLimit;
295  int i, k, c, s;
296 
297  // both cuts are the largest
298  if ( nSizeC0 == nLimit && nSizeC1 == nLimit )
299  {
300  for ( i = 0; i < nSizeC0; i++ )
301  {
302  if ( pC0->pLeaves[i] != pC1->pLeaves[i] )
303  return 0;
304  pC->pLeaves[i] = pC0->pLeaves[i];
305  }
306  pC->nLeaves = nLimit;
307  pC->uSign = pC0->uSign | pC1->uSign;
308  return 1;
309  }
310 
311  // compare two cuts with different numbers
312  i = k = c = s = 0;
313  if ( nSizeC0 == 0 ) goto FlushCut1;
314  if ( nSizeC1 == 0 ) goto FlushCut0;
315  while ( 1 )
316  {
317  if ( c == nLimit ) return 0;
318  if ( pC0->pLeaves[i] < pC1->pLeaves[k] )
319  {
320  pC->pLeaves[c++] = pC0->pLeaves[i++];
321  if ( i == nSizeC0 ) goto FlushCut1;
322  }
323  else if ( pC0->pLeaves[i] > pC1->pLeaves[k] )
324  {
325  pC->pLeaves[c++] = pC1->pLeaves[k++];
326  if ( k == nSizeC1 ) goto FlushCut0;
327  }
328  else
329  {
330  pC->pLeaves[c++] = pC0->pLeaves[i++]; k++;
331  if ( i == nSizeC0 ) goto FlushCut1;
332  if ( k == nSizeC1 ) goto FlushCut0;
333  }
334  }
335 
336 FlushCut0:
337  if ( c + nSizeC0 > nLimit + i ) return 0;
338  while ( i < nSizeC0 )
339  pC->pLeaves[c++] = pC0->pLeaves[i++];
340  pC->nLeaves = c;
341  pC->uSign = pC0->uSign | pC1->uSign;
342  return 1;
343 
344 FlushCut1:
345  if ( c + nSizeC1 > nLimit + k ) return 0;
346  while ( k < nSizeC1 )
347  pC->pLeaves[c++] = pC1->pLeaves[k++];
348  pC->nLeaves = c;
349  pC->uSign = pC0->uSign | pC1->uSign;
350  return 1;
351 }
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int pLeaves[0]
Definition: if.h:290
unsigned uSign
Definition: if.h:283
void If_CutOrder ( If_Cut_t pCut)

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

Synopsis [Orders the leaves of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 797 of file ifCut.c.

798 {
799  int i, Temp, fChanges;
800  do {
801  fChanges = 0;
802  for ( i = 0; i < (int)pCut->nLeaves - 1; i++ )
803  {
804  assert( pCut->pLeaves[i] != pCut->pLeaves[i+1] );
805  if ( pCut->pLeaves[i] <= pCut->pLeaves[i+1] )
806  continue;
807  Temp = pCut->pLeaves[i];
808  pCut->pLeaves[i] = pCut->pLeaves[i+1];
809  pCut->pLeaves[i+1] = Temp;
810  fChanges = 1;
811  }
812  } while ( fChanges );
813 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
#define assert(ex)
Definition: util_old.h:213
int If_CutPerformCheck07 ( If_Man_t p,
unsigned *  pTruth,
int  nVars,
int  nLeaves,
char *  pStr 
)

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 1071 of file ifDec07.c.

1072 {
1073  int fDerive = 0;
1074  int v;
1075  // skip non-support minimal
1076  for ( v = 0; v < nLeaves; v++ )
1077  if ( !Abc_TtHasVar( (word *)pTruth, nVars, v ) )
1078  return 0;
1079  // check
1080  if ( nLeaves < 5 )
1081  return 1;
1082  if ( nLeaves == 5 )
1083  {
1084  word z, t = ((word)pTruth[0] << 32) | (word)pTruth[0];
1085  z = If_Dec5Perform( t, fDerive );
1086  if ( fDerive && z )
1087  If_Dec6Verify( t, z );
1088  return z != 0;
1089  }
1090  if ( nLeaves == 6 )
1091  {
1092  word z, t = ((word *)pTruth)[0];
1093  z = If_Dec6Perform( t, fDerive );
1094  if ( fDerive && z )
1095  {
1096 // If_DecPrintConfig( z );
1097  If_Dec6Verify( t, z );
1098  }
1099 // if ( z == 0 )
1100 // Extra_PrintHex(stdout, (unsigned *)&t, 6), printf( " " ), Kit_DsdPrintFromTruth( (unsigned *)&t, 6 ), printf( "\n" );
1101  return z != 0;
1102  }
1103  if ( nLeaves == 7 )
1104  {
1105  word z, t[2];
1106  t[0] = ((word *)pTruth)[0];
1107  t[1] = ((word *)pTruth)[1];
1108 // if ( If_Dec7CheckMux(t) >= 0 )
1109 // return 1;
1110  z = If_Dec7Perform( t, fDerive );
1111  if ( fDerive && z )
1112  If_Dec7Verify( t, z );
1113  return z != 0;
1114  }
1115  assert( 0 );
1116  return 0;
1117 }
word If_Dec7Perform(word t0[2], int fDerive)
Definition: ifDec07.c:460
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word If_Dec5Perform(word t, int fDerive)
Definition: ifDec07.c:868
static int Abc_TtHasVar(word *t, int nVars, int iVar)
Definition: utilTruth.h:953
void If_Dec6Verify(word t, word z)
Definition: ifDec07.c:142
word If_Dec6Perform(word t, int fDerive)
Definition: ifDec07.c:420
#define assert(ex)
Definition: util_old.h:213
void If_Dec7Verify(word t[2], word z)
Definition: ifDec07.c:174
int If_CutPerformCheck08 ( If_Man_t p,
unsigned *  pTruth,
int  nVars,
int  nLeaves,
char *  pStr 
)

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 481 of file ifDec08.c.

482 {
483  int nSupp, fDerive = 0;
484  word pF[16];
485  if ( nLeaves <= 5 )
486  return 1;
487  If_Dec08Copy( pF, (word *)pTruth, nVars );
488  nSupp = If_Dec08Support( pF, nLeaves );
489  if ( !nSupp || !If_DecSuppIsMinBase(nSupp) )
490  return 0;
491  if ( If_Dec08Perform( pF, nLeaves, fDerive ) )
492  {
493 // printf( "1" );
494  return 1;
495 // If_Dec08Verify( t, nLeaves, NULL );
496  }
497 // printf( "0" );
498  return 0;
499 }
static void If_Dec08Copy(word *pOut, word *pIn, int nVars)
Definition: ifDec08.c:198
static int If_DecSuppIsMinBase(int Supp)
Definition: ifDec08.c:304
static int If_Dec08Support(word *t, int nVars)
Definition: ifDec08.c:333
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int If_Dec08Perform(word *pF, int nVars, int fDerive)
Definition: ifDec08.c:385
int If_CutPerformCheck10 ( If_Man_t p,
unsigned *  pTruth,
int  nVars,
int  nLeaves,
char *  pStr 
)

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 480 of file ifDec10.c.

481 {
482  int nSupp, fDerive = 0;
483  word pF[16];
484  if ( nLeaves <= 6 )
485  return 1;
486  If_Dec10Copy( pF, (word *)pTruth, nVars );
487  nSupp = If_Dec10Support( pF, nLeaves );
488  if ( !nSupp || !If_DecSuppIsMinBase(nSupp) )
489  return 0;
490  if ( If_Dec10Perform( pF, nLeaves, fDerive ) )
491  {
492 // printf( "1" );
493  return 1;
494 // If_Dec10Verify( t, nLeaves, NULL );
495  }
496 // printf( "0" );
497  return 0;
498 }
static int If_Dec10Support(word *t, int nVars)
Definition: ifDec10.c:330
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int If_DecSuppIsMinBase(int Supp)
Definition: ifDec10.c:301
int If_Dec10Perform(word *pF, int nVars, int fDerive)
Definition: ifDec10.c:382
static void If_Dec10Copy(word *pOut, word *pIn, int nVars)
Definition: ifDec10.c:195
int If_CutPerformCheck16 ( If_Man_t p,
unsigned *  pTruth0,
int  nVars,
int  nLeaves,
char *  pStr 
)

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 2216 of file ifDec16.c.

2217 {
2218  unsigned pTruth[IF_MAX_FUNC_LUTSIZE > 5 ? 1 << (IF_MAX_FUNC_LUTSIZE - 5) : 1];
2219  If_Grp_t G1 = {0};//, G3 = {0};
2220  int i, nLutLeaf, nLutLeaf2, nLutRoot, Length;
2221  // stretch the truth table
2222  assert( nVars >= 6 );
2223  memcpy( pTruth, pTruth0, sizeof(word) * Abc_TtWordNum(nVars) );
2224  Abc_TtStretch6( (word *)pTruth, nLeaves, p->pPars->nLutSize );
2225 
2226 #ifdef IF_TRY_NEW
2227  {
2228  word pCopy[1024];
2229  int nWords = Abc_TruthWordNum(nVars);
2230  int iNum;
2231  if ( s_vTtMem == NULL )
2232  {
2233  s_vTtMem = Vec_MemAlloc( Abc_Truth6WordNum(nVars), 12 ); // 32 KB/page for 6-var functions
2234  Vec_MemHashAlloc( s_vTtMem, 10000 );
2235  }
2236  if ( s_vTtMem2 == NULL )
2237  {
2238  s_vTtMem2 = Vec_MemAlloc( Abc_Truth6WordNum(nVars), 12 ); // 32 KB/page for 6-var functions
2239  Vec_MemHashAlloc( s_vTtMem2, 10000 );
2240  }
2241  memcpy( pCopy, pTruth, sizeof(word) * Abc_Truth6WordNum(nVars) );
2242  if ( pCopy[0] & 1 )
2243  for ( i = 0; i < nWords; i++ )
2244  pCopy[i] = ~pCopy[i];
2245  iNum = Vec_MemHashInsert( s_vTtMem, pCopy );
2246  if ( iNum == Vec_MemEntryNum(s_vTtMem) - 1 )
2247  {
2248  int pCanonPerm[16];
2249  char pCanonPermC[16];
2250  Abc_TtCanonicize( pCopy, nVars, pCanonPermC );
2251 // If_CluSemiCanonicize( pCopy, nVars, pCanonPerm );
2252  Vec_MemHashInsert( s_vTtMem2, pCopy );
2253  }
2254  }
2255 #endif
2256 
2257  // if cutmin is disabled, minimize the function
2258  if ( !p->pPars->fCutMin )
2259  nLeaves = Abc_TtMinBase( (word *)pTruth, NULL, nLeaves, nVars );
2260 
2261  // quit if parameters are wrong
2262  Length = strlen(pStr);
2263  if ( Length != 2 && Length != 3 )
2264  {
2265  printf( "Wrong LUT struct (%s)\n", pStr );
2266  return 0;
2267  }
2268  for ( i = 0; i < Length; i++ )
2269  if ( pStr[i] - '0' < 3 || pStr[i] - '0' > 6 )
2270  {
2271  printf( "The LUT size (%d) should belong to {3,4,5,6}.\n", pStr[i] - '0' );
2272  return 0;
2273  }
2274 
2275  nLutLeaf = pStr[0] - '0';
2276  nLutLeaf2 = ( Length == 3 ) ? pStr[1] - '0' : 0;
2277  nLutRoot = pStr[Length-1] - '0';
2278  if ( nLeaves > nLutLeaf - 1 + (nLutLeaf2 ? nLutLeaf2 - 1 : 0) + nLutRoot )
2279  {
2280  printf( "The cut size (%d) is too large for the LUT structure %s.\n", nLeaves, pStr );
2281  return 0;
2282  }
2283  // consider easy case
2284  if ( nLeaves <= Abc_MaxInt( nLutLeaf2, Abc_MaxInt(nLutLeaf, nLutRoot) ) )
2285  return 1;
2286 
2287  // derive the first group
2288  if ( Length == 2 )
2289  G1 = If_CluCheck( p, (word *)pTruth, nLeaves, 0, 0, nLutLeaf, nLutRoot, NULL, NULL, NULL, NULL, 1 );
2290  else
2291  G1 = If_CluCheck3( p, (word *)pTruth, nLeaves, nLutLeaf, nLutLeaf2, nLutRoot, NULL, NULL, NULL, NULL, NULL );
2292 
2293 // if ( G1.nVars > 0 )
2294 // If_CluPrintGroup( &G1 );
2295 
2296  return (int)(G1.nVars > 0);
2297 }
static int Abc_TtMinBase(word *pTruth, int *pVars, int nVars, int nVarsAll)
Definition: utilTruth.h:1395
int nLutSize
Definition: if.h:103
If_Grp_t If_CluCheck(If_Man_t *p, word *pTruth0, int nVars, int iVarStart, int iVarStop, int nLutLeaf, int nLutRoot, If_Grp_t *pR, word *pFunc0, word *pFunc1, word *pLeftOver, int fHashing)
Definition: ifDec16.c:1553
static void Vec_MemHashAlloc(Vec_Mem_t *p, int nTableSize)
Definition: vecMem.h:305
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
char * memcpy()
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
If_Grp_t If_CluCheck3(If_Man_t *p, word *pTruth0, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, If_Grp_t *pR, If_Grp_t *pG2, word *pFunc0, word *pFunc1, word *pFunc2)
Definition: ifDec16.c:1909
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int nWords
Definition: abcNpn.c:127
static Vec_Mem_t * Vec_MemAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: utilMem.c:70
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TtStretch6(word *pInOut, int nVarS, int nVarB)
Definition: utilTruth.h:693
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
If_Par_t * pPars
Definition: if.h:184
static int Abc_TtWordNum(int nVars)
Definition: utilTruth.h:169
unsigned Abc_TtCanonicize(word *pTruth, int nVars, char *pCanonPerm)
FUNCTION DECLARATIONS ///.
Definition: dauCanon.c:895
int fCutMin
Definition: if.h:120
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
#define assert(ex)
Definition: util_old.h:213
int strlen()
static Vec_Mem_t * s_vTtMem
Definition: giaMf.c:117
int If_CutPerformCheck45 ( If_Man_t p,
unsigned *  pTruth,
int  nVars,
int  nLeaves,
char *  pStr 
)

Definition at line 1865 of file ifDec16.c.

1866 {
1867  // 5LUT -> 4LUT
1868  If_Grp_t G, R;
1869  word Func0, Func1;
1870  G = If_CluCheck( p, (word *)pTruth, nLeaves, 0, 0, 5, 4, &R, &Func0, &Func1, NULL, 0 );
1871  if ( G.nVars == 0 )
1872  return 0;
1873  Func0 = If_CluAdjust( Func0, R.nVars );
1874  Func1 = If_CluAdjust( Func1, G.nVars );
1875 #if 0
1876  Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
1877  Kit_DsdPrintFromTruth( (unsigned*)&Func0, R.nVars ); printf( "\n" );
1878  Kit_DsdPrintFromTruth( (unsigned*)&Func1, G.nVars ); printf( "\n" );
1879  If_CluPrintGroup( &R );
1880  If_CluPrintGroup( &G );
1881 #endif
1882  if ( G.nVars < 5 || (p->pPars->fEnableCheck75 && If_CluCheckDecOut(Func1, 5)) || (p->pPars->fEnableCheck75u && If_CluCheckDecOutU(Func1, 5)) )
1883  return 1;
1884  return 0;
1885 }
int If_CluCheckDecOut(word t, int nVars)
Definition: ifDec16.c:1840
If_Grp_t If_CluCheck(If_Man_t *p, word *pTruth0, int nVars, int iVarStart, int iVarStop, int nLutLeaf, int nLutRoot, If_Grp_t *pR, word *pFunc0, word *pFunc1, word *pLeftOver, int fHashing)
Definition: ifDec16.c:1553
int If_CluCheckDecOutU(word t, int nVars)
Definition: ifDec16.c:1853
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
int fEnableCheck75u
Definition: if.h:132
int fEnableCheck75
Definition: if.h:131
void If_CluPrintGroup(If_Grp_t *g)
Definition: ifDec16.c:580
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
If_Par_t * pPars
Definition: if.h:184
static word If_CluAdjust(word t, int nVars)
Definition: ifDec16.c:370
char nVars
Definition: ifDec16.c:40
int If_CutPerformCheck54 ( If_Man_t p,
unsigned *  pTruth,
int  nVars,
int  nLeaves,
char *  pStr 
)

Definition at line 1886 of file ifDec16.c.

1887 {
1888  // 4LUT -> 5LUT
1889  If_Grp_t G, R;
1890  word Func0, Func1;
1891  G = If_CluCheck( p, (word *)pTruth, nLeaves, 0, 0, 4, 5, &R, &Func0, &Func1, NULL, 0 );
1892  if ( G.nVars == 0 )
1893  return 0;
1894  Func0 = If_CluAdjust( Func0, R.nVars );
1895  Func1 = If_CluAdjust( Func1, G.nVars );
1896 #if 0
1897  Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
1898  Kit_DsdPrintFromTruth( (unsigned*)&Func0, R.nVars ); printf( "\n" );
1899  Kit_DsdPrintFromTruth( (unsigned*)&Func1, G.nVars ); printf( "\n" );
1900  If_CluPrintGroup( &R );
1901  If_CluPrintGroup( &G );
1902 #endif
1903  if ( R.nVars < 5 || (p->pPars->fEnableCheck75 && If_CluCheckDecIn(Func0, 5)) || (p->pPars->fEnableCheck75u && If_CluCheckDecInU(Func0, 5)) )
1904  return 1;
1905  return 0;
1906 }
int If_CluCheckDecInU(word t, int nVars)
Definition: ifDec16.c:1818
If_Grp_t If_CluCheck(If_Man_t *p, word *pTruth0, int nVars, int iVarStart, int iVarStop, int nLutLeaf, int nLutRoot, If_Grp_t *pR, word *pFunc0, word *pFunc1, word *pLeftOver, int fHashing)
Definition: ifDec16.c:1553
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
int fEnableCheck75u
Definition: if.h:132
int fEnableCheck75
Definition: if.h:131
void If_CluPrintGroup(If_Grp_t *g)
Definition: ifDec16.c:580
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
If_Par_t * pPars
Definition: if.h:184
static word If_CluAdjust(word t, int nVars)
Definition: ifDec16.c:370
char nVars
Definition: ifDec16.c:40
int If_CluCheckDecIn(word t, int nVars)
Definition: ifDec16.c:1792
int If_CutPerformCheck75 ( If_Man_t p,
unsigned *  pTruth0,
int  nVars,
int  nLeaves,
char *  pStr 
)

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 303 of file ifDec75.c.

304 {
305  word * pTruthW = (word *)pTruth0;
306  word pTruth[4] = { pTruthW[0], pTruthW[1], pTruthW[2], pTruthW[3] };
307  assert( nLeaves <= 8 );
308  if ( !p->pPars->fCutMin )
309  Abc_TtMinimumBase( pTruth, NULL, nLeaves, &nLeaves );
310  if ( nLeaves < 6 )
311  return 1;
312 // if ( nLeaves < 8 && If_CutPerformCheck07( p, (unsigned *)pTruth, nVars, nLeaves, "44" ) )
313  if ( nLeaves < 8 && If_CutPerformCheck16( p, (unsigned *)pTruth, nVars, nLeaves, "44" ) )
314  return 1;
315  // this is faster but not compatible with -z
316  if ( !p->pPars->fDeriveLuts && p->pPars->fEnableCheck75 && nLeaves == 8 )
317  {
318 // char pDsdStr[1000] = "(!(abd)!(c!([fe][gh])))";
319  char pDsdStr[1000];
320  int nSizeNonDec = Dau_DsdDecompose( (word *)pTruth, nLeaves, 0, 0, pDsdStr );
321  if ( nSizeNonDec >= 5 )
322  return 0;
323  if ( Dau_DsdCheckDecAndExist(pDsdStr) & 0x10 ) // bit 4
324  return 1;
325  return 0;
326  }
327  if ( If_CutPerformCheck45( p, (unsigned *)pTruth, nVars, nLeaves, pStr ) )
328  return 1;
329  if ( If_CutPerformCheck54( p, (unsigned *)pTruth, nVars, nLeaves, pStr ) )
330  return 1;
331  return 0;
332 }
static int Abc_TtMinimumBase(word *t, int *pSupp, int nVarsAll, int *pnVars)
Definition: utilTruth.h:1314
int fDeriveLuts
Definition: if.h:138
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition: dauDsd.c:1912
int Dau_DsdCheckDecAndExist(char *pDsd)
Definition: ifDec75.c:185
int If_CutPerformCheck54(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition: ifDec16.c:1886
int fEnableCheck75
Definition: if.h:131
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
If_Par_t * pPars
Definition: if.h:184
int fCutMin
Definition: if.h:120
#define assert(ex)
Definition: util_old.h:213
int If_CutPerformCheck16(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition: ifDec16.c:2216
int If_CutPerformCheck45(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition: ifDec16.c:1865
word If_CutPerformDerive07 ( If_Man_t p,
unsigned *  pTruth,
int  nVars,
int  nLeaves,
char *  pStr 
)

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

Synopsis [Performs additional check.]

Description []

SideEffects []

SeeAlso []

Definition at line 1029 of file ifDec07.c.

1030 {
1031  if ( nLeaves < 5 )
1032  return 1;
1033  if ( nLeaves == 5 )
1034  {
1035  word z, t = ((word)pTruth[0] << 32) | (word)pTruth[0];
1036  z = If_Dec5Perform( t, 1 );
1037  If_Dec6Verify( t, z );
1038  return z;
1039  }
1040  if ( nLeaves == 6 )
1041  {
1042  word z, t = ((word *)pTruth)[0];
1043  z = If_Dec6Perform( t, 1 );
1044  If_Dec6Verify( t, z );
1045  return z;
1046  }
1047  if ( nLeaves == 7 )
1048  {
1049  word z, t[2];
1050  t[0] = ((word *)pTruth)[0];
1051  t[1] = ((word *)pTruth)[1];
1052  z = If_Dec7Perform( t, 1 );
1053  If_Dec7Verify( t, z );
1054  return z;
1055  }
1056  assert( 0 );
1057  return 0;
1058 }
word If_Dec7Perform(word t0[2], int fDerive)
Definition: ifDec07.c:460
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word If_Dec5Perform(word t, int fDerive)
Definition: ifDec07.c:868
void If_Dec6Verify(word t, word z)
Definition: ifDec07.c:142
word If_Dec6Perform(word t, int fDerive)
Definition: ifDec07.c:420
#define assert(ex)
Definition: util_old.h:213
void If_Dec7Verify(word t[2], word z)
Definition: ifDec07.c:174
static char* If_CutPerm ( If_Cut_t pCut)
inlinestatic

Definition at line 397 of file if.h.

397 { return (char *)(pCut->pLeaves + pCut->nLeaves); }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
static int If_CutPermWords ( int  nVarsMax)
inlinestatic

Definition at line 395 of file if.h.

395 { return nVarsMax / sizeof(int) + ((nVarsMax % sizeof(int)) > 0); }
float If_CutPowerDeref ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1234 of file ifCut.c.

1235 {
1236  If_Obj_t * pLeaf;
1237  float * pSwitching = (float *)p->vSwitching->pArray;
1238  float Power = 0;
1239  int i;
1240  If_CutForEachLeaf( p, pCut, pLeaf, i )
1241  {
1242  Power += pSwitching[pLeaf->Id];
1243  assert( pLeaf->nRefs > 0 );
1244  if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) )
1245  continue;
1246  Power += If_CutPowerDeref( p, If_ObjCutBest(pLeaf), pRoot );
1247  }
1248  return Power;
1249 }
int Id
Definition: if.h:316
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
Vec_Int_t * vSwitching
Definition: if.h:208
int nRefs
Definition: if.h:318
float If_CutPowerDeref(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1234
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerDerefed ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes Power of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1290 of file ifCut.c.

1291 {
1292  float aResult, aResult2;
1293  if ( pCut->nLeaves < 2 )
1294  return 0;
1295  aResult2 = If_CutPowerRef( p, pCut, pRoot );
1296  aResult = If_CutPowerDeref( p, pCut, pRoot );
1297  assert( aResult > aResult2 - p->fEpsilon );
1298  assert( aResult < aResult2 + p->fEpsilon );
1299  return aResult;
1300 }
unsigned nLeaves
Definition: if.h:289
float If_CutPowerDeref(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1234
float fEpsilon
Definition: if.h:195
float If_CutPowerRef(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1262
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerFlow ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area flow.]

Description []

SideEffects []

SeeAlso []

Definition at line 979 of file ifCut.c.

980 {
981  If_Obj_t * pLeaf;
982  float * pSwitching = (float *)p->vSwitching->pArray;
983  float Power = 0;
984  int i;
985  If_CutForEachLeaf( p, pCut, pLeaf, i )
986  {
987  Power += pSwitching[pLeaf->Id];
988  if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
989  Power += If_ObjCutBest(pLeaf)->Power;
990  else
991  {
992  assert( pLeaf->EstRefs > p->fEpsilon );
993  Power += If_ObjCutBest(pLeaf)->Power / pLeaf->EstRefs;
994  }
995  }
996  return Power;
997 }
int Id
Definition: if.h:316
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
Vec_Int_t * vSwitching
Definition: if.h:208
int nRefs
Definition: if.h:318
float Power
Definition: if.h:279
float fEpsilon
Definition: if.h:195
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerRef ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1262 of file ifCut.c.

1263 {
1264  If_Obj_t * pLeaf;
1265  float * pSwitching = (float *)p->vSwitching->pArray;
1266  float Power = 0;
1267  int i;
1268  If_CutForEachLeaf( p, pCut, pLeaf, i )
1269  {
1270  Power += pSwitching[pLeaf->Id];
1271  assert( pLeaf->nRefs >= 0 );
1272  if ( pLeaf->nRefs++ > 0 || !If_ObjIsAnd(pLeaf) )
1273  continue;
1274  Power += If_CutPowerRef( p, If_ObjCutBest(pLeaf), pRoot );
1275  }
1276  return Power;
1277 }
int Id
Definition: if.h:316
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
Vec_Int_t * vSwitching
Definition: if.h:208
int nRefs
Definition: if.h:318
float If_CutPowerRef(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1262
#define assert(ex)
Definition: util_old.h:213
float If_CutPowerRefed ( If_Man_t p,
If_Cut_t pCut,
If_Obj_t pRoot 
)

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

Synopsis [Computes area of the first level.]

Description [The cut need to be derefed.]

SideEffects []

SeeAlso []

Definition at line 1313 of file ifCut.c.

1314 {
1315  float aResult, aResult2;
1316  if ( pCut->nLeaves < 2 )
1317  return 0;
1318  aResult2 = If_CutPowerDeref( p, pCut, pRoot );
1319  aResult = If_CutPowerRef( p, pCut, pRoot );
1320  assert( aResult > aResult2 - p->fEpsilon );
1321  assert( aResult < aResult2 + p->fEpsilon );
1322  return aResult;
1323 }
unsigned nLeaves
Definition: if.h:289
float If_CutPowerDeref(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1234
float fEpsilon
Definition: if.h:195
float If_CutPowerRef(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1262
#define assert(ex)
Definition: util_old.h:213
void If_CutPrint ( If_Cut_t pCut)

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

Synopsis [Prints one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 856 of file ifCut.c.

857 {
858  unsigned i;
859  Abc_Print( 1, "{" );
860  for ( i = 0; i < pCut->nLeaves; i++ )
861  Abc_Print( 1, " %s%d", If_CutLeafBit(pCut, i) ? "!":"", pCut->pLeaves[i] );
862  Abc_Print( 1, " }\n" );
863 }
unsigned nLeaves
Definition: if.h:289
int pLeaves[0]
Definition: if.h:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int If_CutLeafBit(If_Cut_t *pCut, int i)
Definition: if.h:396
void If_CutPrintTiming ( If_Man_t p,
If_Cut_t pCut 
)

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

Synopsis [Prints one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 876 of file ifCut.c.

877 {
878  If_Obj_t * pLeaf;
879  unsigned i;
880  Abc_Print( 1, "{" );
881  If_CutForEachLeaf( p, pCut, pLeaf, i )
882  Abc_Print( 1, " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required );
883  Abc_Print( 1, " }\n" );
884 }
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void If_CutPropagateRequired ( If_Man_t p,
If_Obj_t pObj,
If_Cut_t pCut,
float  ObjRequired 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 170 of file ifTime.c.

171 {
172  static int pPinPerm[IF_MAX_LUTSIZE];
173  static float pPinDelays[IF_MAX_LUTSIZE];
174  If_Obj_t * pLeaf;
175  float * pLutDelays;
176  float Required;
177  int i, Pin2PinDelay;//, iLeaf;
178  assert( !p->pPars->fLiftLeaves );
179  // compute the pins
180  if ( p->pPars->pLutLib )
181  {
182  pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
183  if ( p->pPars->pLutLib->fVarPinDelays )
184  {
185  // compute the delay using sorted pins
186  If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
187  for ( i = 0; i < (int)pCut->nLeaves; i++ )
188  {
189  Required = ObjRequired - pLutDelays[i];
190  pLeaf = If_ManObj( p, pCut->pLeaves[pPinPerm[i]] );
191  pLeaf->Required = IF_MIN( pLeaf->Required, Required );
192  }
193  }
194  else
195  {
196  Required = ObjRequired;
197  If_CutForEachLeaf( p, pCut, pLeaf, i )
198  pLeaf->Required = IF_MIN( pLeaf->Required, Required - pLutDelays[0] );
199  }
200  }
201  else
202  {
203  if ( pCut->fUser )
204  {
205  char Perm[IF_MAX_FUNC_LUTSIZE], * pPerm = Perm;
206  if ( p->pPars->fDelayOpt )
207  {
208  int Delay = If_CutSopBalancePinDelays( p, pCut, pPerm );
209  assert( Delay == (int)pCut->Delay );
210  }
211  else if ( p->pPars->fDelayOptLut )
212  {
213  int Delay = If_CutLutBalancePinDelays( p, pCut, pPerm );
214  assert( Delay == (int)pCut->Delay );
215  }
216  else if ( p->pPars->fDsdBalance )
217  {
218  int Delay = If_CutDsdBalancePinDelays( p, pCut, pPerm );
219  assert( Delay == (int)pCut->Delay );
220  }
221  else
222  pPerm = If_CutPerm(pCut);
223  If_CutForEachLeaf( p, pCut, pLeaf, i )
224  {
225  Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
226  Required = ObjRequired - (float)Pin2PinDelay;
227  pLeaf->Required = IF_MIN( pLeaf->Required, Required );
228  }
229  }
230  else
231  {
232  Required = ObjRequired;
233  If_CutForEachLeaf( p, pCut, pLeaf, i )
234  pLeaf->Required = IF_MIN( pLeaf->Required, Required - (float)1.0 );
235  }
236  }
237 }
unsigned nLeaves
Definition: if.h:289
int If_CutSopBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
Definition: ifDelay.c:159
static If_Obj_t * If_ManObj(If_Man_t *p, int i)
Definition: if.h:370
Definition: if.h:303
#define IF_BIG_CHAR
Definition: if.h:60
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
float Required
Definition: if.h:325
int fDelayOptLut
Definition: if.h:122
static char * If_CutPerm(If_Cut_t *pCut)
Definition: if.h:397
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
unsigned fUser
Definition: if.h:286
int pLeaves[0]
Definition: if.h:290
int fDsdBalance
Definition: if.h:123
int fVarPinDelays
Definition: if.h:174
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
else
Definition: sparse_int.h:55
#define IF_MIN(a, b)
MACRO DEFINITIONS ///.
Definition: if.h:436
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
int If_CutLutBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
Definition: ifDelay.c:327
static int pPerm[13719]
Definition: rwrTemp.c:32
If_Par_t * pPars
Definition: if.h:184
ABC_NAMESPACE_IMPL_START void If_CutSortInputPins(If_Man_t *p, If_Cut_t *pCut, int *pPinPerm, float *pPinDelays)
DECLARATIONS ///.
Definition: ifTime.c:44
int fDelayOpt
Definition: if.h:121
#define assert(ex)
Definition: util_old.h:213
int fLiftLeaves
Definition: if.h:156
float Delay
Definition: if.h:280
int If_CutDsdBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
Definition: ifDsd.c:2152
If_LibLut_t * pLutLib
Definition: if.h:160
void If_CutRotatePins ( If_Man_t p,
If_Cut_t pCut 
)

Definition at line 67 of file ifTruth.c.

68 {
69  If_Obj_t * pLeaf;
70  float PinDelays[IF_MAX_LUTSIZE];
71  int i, truthId;
72  assert( !p->pPars->fUseTtPerm );
73  If_CutForEachLeaf( p, pCut, pLeaf, i )
74  PinDelays[i] = If_ObjCutBest(pLeaf)->Delay;
75  if ( p->vTtMem[pCut->nLeaves] == NULL )
76  {
77  If_CutTruthPermute( NULL, If_CutLeaveNum(pCut), pCut->nLeaves, p->nTruth6Words[pCut->nLeaves], PinDelays, If_CutLeaves(pCut) );
78  return;
79  }
80  Abc_TtCopy( p->puTempW, If_CutTruthWR(p, pCut), p->nTruth6Words[pCut->nLeaves], 0 );
81  If_CutTruthPermute( p->puTempW, If_CutLeaveNum(pCut), pCut->nLeaves, p->nTruth6Words[pCut->nLeaves], PinDelays, If_CutLeaves(pCut) );
82  truthId = Vec_MemHashInsert( p->vTtMem[pCut->nLeaves], p->puTempW );
83  pCut->iCutFunc = Abc_Var2Lit( truthId, If_CutTruthIsCompl(pCut) );
84  assert( (p->puTempW[0] & 1) == 0 );
85 }
int nTruth6Words[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:226
unsigned nLeaves
Definition: if.h:289
ABC_NAMESPACE_IMPL_START void If_CutTruthPermute(word *pTruth, int nLeaves, int nVars, int nWords, float *pDelays, int *pVars)
DECLARATIONS ///.
Definition: ifTruth.c:48
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:244
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
static int If_CutTruthIsCompl(If_Cut_t *pCut)
Definition: if.h:418
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
static word * If_CutTruthWR(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:419
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
static int * If_CutLeaves(If_Cut_t *pCut)
Definition: if.h:391
if(last==0)
Definition: sparse_int.h:34
word * puTempW
Definition: if.h:204
If_Par_t * pPars
Definition: if.h:184
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
int fUseTtPerm
Definition: if.h:137
#define assert(ex)
Definition: util_old.h:213
int iCutFunc
Definition: if.h:281
static void If_CutSetData ( If_Cut_t pCut,
void *  pData 
)
inlinestatic

Definition at line 412 of file if.h.

412 { *(void **)pCut = pData; }
static void If_CutSetDataInt ( If_Cut_t pCut,
int  Data 
)
inlinestatic

Definition at line 415 of file if.h.

415 { *(int *)pCut = Data; }
static void If_CutSetup ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 399 of file if.h.

399 { memset(pCut, 0, p->nCutBytes); pCut->nLimit = p->pPars->nLutSize; }
char * memset()
unsigned nLimit
Definition: if.h:288
int nLutSize
Definition: if.h:103
If_Par_t * pPars
Definition: if.h:184
int nCutBytes
Definition: if.h:229
int If_CutSopBalanceEval ( If_Man_t p,
If_Cut_t pCut,
Vec_Int_t vAig 
)

Definition at line 248 of file ifDelay.c.

249 {
250  pCut->fUser = 1;
251  if ( vAig )
252  Vec_IntClear( vAig );
253  if ( pCut->nLeaves == 0 ) // const
254  {
255  assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
256  if ( vAig )
257  Vec_IntPush( vAig, Abc_LitIsCompl(If_CutTruthLit(pCut)) );
258  pCut->Cost = 0;
259  return 0;
260  }
261  if ( pCut->nLeaves == 1 ) // variable
262  {
263  assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
264  if ( vAig )
265  Vec_IntPush( vAig, 0 );
266  if ( vAig )
267  Vec_IntPush( vAig, Abc_LitIsCompl(If_CutTruthLit(pCut)) );
268  pCut->Cost = 0;
269  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
270  }
271  else
272  {
273  int fVerbose = 0;
274  Vec_Int_t * vCover = Vec_WecEntry( p->vTtIsops[pCut->nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
275  int Delay, Area = 0;
276  int i, pTimes[IF_MAX_FUNC_LUTSIZE];
277  if ( vCover == NULL )
278  return -1;
279  assert( Vec_IntSize(vCover) > 0 );
280  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
281  pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
282  Delay = If_CutSopBalanceEvalIntInt( vCover, If_CutLeaveNum(pCut), pTimes, vAig, Abc_LitIsCompl(If_CutTruthLit(pCut)) ^ pCut->fCompl, &Area );
283  pCut->Cost = Area;
284  if ( fVerbose )
285  {
286  int Max = 0, Two = 0;
287  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
288  Max = Abc_MaxInt( Max, pTimes[i] );
289  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
290  if ( pTimes[i] != Max )
291  Two = Abc_MaxInt( Two, pTimes[i] );
292  if ( Two + 2 < Max && Max + 3 < Delay )
293  {
294  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
295  printf( "%3d ", pTimes[i] );
296  for ( ; i < p->pPars->nLutSize; i++ )
297  printf( " " );
298  printf( "-> %3d ", Delay );
301  {
302  Vec_Int_t vIsop;
303  int pIsop[64];
304  vIsop.nCap = vIsop.nSize = Abc_Tt6Esop( *If_CutTruthW(p, pCut), pCut->nLeaves, pIsop );
305  vIsop.pArray = pIsop;
306  printf( "ESOP (%d -> %d)\n", Vec_IntSize(vCover), vIsop.nSize );
307  Kit_TruthIsopPrintCover( &vIsop, If_CutLeaveNum(pCut), 0 );
308  }
309  printf( "\n" );
310  }
311  }
312  return Delay;
313  }
314 }
unsigned nLeaves
Definition: if.h:289
int nLutSize
Definition: if.h:103
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:245
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
unsigned fUser
Definition: if.h:286
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
unsigned Cost
Definition: if.h:284
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
Definition: kitIsop.c:104
int If_CutSopBalanceEvalIntInt(Vec_Int_t *vCover, int nLeaves, int *pTimes, Vec_Int_t *vAig, int fCompl, int *pArea)
Definition: ifDelay.c:232
static int If_CutTruthLit(If_Cut_t *pCut)
Definition: if.h:417
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
If_Par_t * pPars
Definition: if.h:184
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
unsigned fCompl
Definition: if.h:285
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
float Delay
Definition: if.h:280
static int Abc_Tt6Esop(word t, int nVars, int *pCover)
Definition: utilTruth.h:2000
int If_CutSopBalanceEvalInt ( Vec_Int_t vCover,
int *  pTimes,
int *  pFaninLits,
Vec_Int_t vAig,
int *  piRes,
int  nSuppAll,
int *  pArea 
)

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

Synopsis [Evaluate delay using SOP balancing.]

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file ifDelay.c.

193 {
194  int nCounterAnd, pCounterAnd[IF_MAX_FUNC_LUTSIZE], pFaninLitsAnd[IF_MAX_FUNC_LUTSIZE];
195  int nCounterOr, pCounterOr[IF_MAX_CUBES], pFaninLitsOr[IF_MAX_CUBES];
196  int i, k, Entry, Literal, nLits, Delay = 0, iRes = 0;
197  if ( Vec_IntSize(vCover) > IF_MAX_CUBES )
198  return -1;
199  nCounterOr = 0;
200  Vec_IntForEachEntry( vCover, Entry, i )
201  {
202  nCounterAnd = nLits = 0;
203  for ( k = 0; k < nSuppAll; k++ )
204  {
205  Literal = 3 & (Entry >> (k << 1));
206  if ( Literal == 1 ) // neg literal
207  nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], Abc_LitNot(pFaninLits[k]), vAig, nSuppAll, 0, 0 );
208  else if ( Literal == 2 ) // pos literal
209  nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], pFaninLits[k], vAig, nSuppAll, 0, 0 );
210  else if ( Literal != 0 )
211  assert( 0 );
212  }
213  assert( nCounterAnd > 0 );
214  assert( nLits > 0 );
215  if ( vAig )
216  iRes = If_LogCreateAndXorMulti( vAig, pFaninLitsAnd, nCounterAnd, nSuppAll, 0 );
217  else
218  *pArea += nLits == 1 ? 0 : nLits - 1;
219  Delay = If_LogCounterAddAig( pCounterOr, &nCounterOr, pFaninLitsOr, Delay, Abc_LitNot(iRes), vAig, nSuppAll, 0, 0 );
220  }
221  assert( nCounterOr > 0 );
222  if ( vAig )
223  {
224  *piRes = Abc_LitNot( If_LogCreateAndXorMulti( vAig, pFaninLitsOr, nCounterOr, nSuppAll, 0 ) );
225  if ( ((vCover->nCap >> 16) & 1) ) // hack to remember complemented attribute
226  *piRes = Abc_LitNot( *piRes );
227  }
228  else
229  *pArea += Vec_IntSize(vCover) == 1 ? 0 : Vec_IntSize(vCover) - 1;
230  return Delay;
231 }
static int If_LogCounterAddAig(int *pTimes, int *pnTimes, int *pFaninLits, int Num, int iLit, Vec_Int_t *vAig, int nSuppAll, int fXor, int fXorFunc)
Definition: ifCount.h:88
#define IF_MAX_CUBES
DECLARATIONS ///.
Definition: ifDelay.c:31
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static int If_LogCreateAndXorMulti(Vec_Int_t *vAig, int *pFaninLits, int nFanins, int nSuppAll, int fXor)
Definition: ifCount.h:80
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int If_CutSopBalancePinDelays ( If_Man_t p,
If_Cut_t pCut,
char *  pPerm 
)

Definition at line 159 of file ifDelay.c.

160 {
161  if ( pCut->nLeaves == 0 ) // const
162  return 0;
163  if ( pCut->nLeaves == 1 ) // variable
164  {
165  pPerm[0] = 0;
166  return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
167  }
168  else
169  {
170  Vec_Int_t * vCover;
171  int i, pTimes[IF_MAX_FUNC_LUTSIZE];
172  vCover = Vec_WecEntry( p->vTtIsops[pCut->nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
173  if ( Vec_IntSize(vCover) == 0 )
174  return -1;
175  for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
176  pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
177  return If_CutSopBalancePinDelaysIntInt( vCover, pTimes, If_CutLeaveNum(pCut), pPerm );
178  }
179 }
unsigned nLeaves
Definition: if.h:289
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:245
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int If_CutSopBalancePinDelaysIntInt(Vec_Int_t *vCover, int *pTimes, int nSuppAll, char *pPerm)
Definition: ifDelay.c:149
static int If_CutTruthLit(If_Cut_t *pCut)
Definition: if.h:417
static If_Obj_t * If_CutLeaf(If_Man_t *p, If_Cut_t *pCut, int i)
Definition: if.h:392
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static int pPerm[13719]
Definition: rwrTemp.c:32
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
float Delay
Definition: if.h:280
int If_CutSopBalancePinDelaysInt ( Vec_Int_t vCover,
int *  pTimes,
word pFaninRes,
int  nSuppAll,
word pRes 
)

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

Synopsis [Compute pin delays.]

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file ifDelay.c.

121 {
122  word pPinDelsAnd[IF_MAX_FUNC_LUTSIZE], pPinDelsOr[IF_MAX_CUBES];
123  int nCounterAnd, pCounterAnd[IF_MAX_FUNC_LUTSIZE];
124  int nCounterOr, pCounterOr[IF_MAX_CUBES];
125  int i, k, Entry, Literal, Delay = 0;
126  word ResAnd;
127  if ( Vec_IntSize(vCover) > IF_MAX_CUBES )
128  return -1;
129  nCounterOr = 0;
130  Vec_IntForEachEntry( vCover, Entry, i )
131  {
132  nCounterAnd = 0;
133  for ( k = 0; k < nSuppAll; k++ )
134  {
135  Literal = 3 & (Entry >> (k << 1));
136  if ( Literal == 1 || Literal == 2 ) // neg or pos literal
137  Delay = If_LogCounterPinDelays( pCounterAnd, &nCounterAnd, pPinDelsAnd, pTimes[k], pFaninRes[k], nSuppAll, 0 );
138  else if ( Literal != 0 )
139  assert( 0 );
140  }
141  assert( nCounterAnd > 0 );
142  ResAnd = If_LogPinDelaysMulti( pPinDelsAnd, nCounterAnd, nSuppAll, 0 );
143  Delay = If_LogCounterPinDelays( pCounterOr, &nCounterOr, pPinDelsOr, Delay, ResAnd, nSuppAll, 0 );
144  }
145  assert( nCounterOr > 0 );
146  *pRes = If_LogPinDelaysMulti( pPinDelsOr, nCounterOr, nSuppAll, 0 );
147  return Delay;
148 }
static word If_LogPinDelaysMulti(word *pPinDels, int nFanins, int nSuppAll, int fXor)
Definition: ifCount.h:230
static int If_LogCounterPinDelays(int *pTimes, int *pnTimes, word *pPinDels, int Num, word PinDel, int nSuppAll, int fXor)
Definition: ifCount.h:199
#define IF_MAX_CUBES
DECLARATIONS ///.
Definition: ifDelay.c:31
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void If_CutSort ( If_Man_t p,
If_Set_t pCutSet,
If_Cut_t pCut 
)

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

Synopsis [Performs incremental sorting of cuts.]

Description [Currently only the trivial sorting is implemented.]

SideEffects []

SeeAlso []

Definition at line 738 of file ifCut.c.

739 {
740 // int Counter = 0;
741  int i;
742 
743  // the new cut is the last one
744  assert( pCutSet->ppCuts[pCutSet->nCuts] == pCut );
745  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
746 
747  // cut structure is empty
748  if ( pCutSet->nCuts == 0 )
749  {
750  pCutSet->nCuts++;
751  return;
752  }
753 
754  if ( !pCut->fUseless &&
755  (p->pPars->fUseDsd || p->pPars->fUseBat ||
756  p->pPars->pLutStruct || p->pPars->fUserRecLib ||
757  p->pPars->fEnableCheck07 || p->pPars->fUseCofVars || p->pPars->fUseAndVars ||
759  {
760  If_Cut_t * pFirst = pCutSet->ppCuts[0];
761  if ( pFirst->fUseless || If_ManSortCompare(p, pFirst, pCut) == 1 )
762  {
763  pCutSet->ppCuts[0] = pCut;
764  pCutSet->ppCuts[pCutSet->nCuts] = pFirst;
765  If_CutSort( p, pCutSet, pFirst );
766  return;
767  }
768  }
769 
770  // the cut will be added - find its place
771  for ( i = pCutSet->nCuts-1; i >= 0; i-- )
772  {
773 // Counter++;
774  if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 || (i == 0 && !pCutSet->ppCuts[0]->fUseless && pCut->fUseless) )
775  break;
776  pCutSet->ppCuts[i+1] = pCutSet->ppCuts[i];
777  pCutSet->ppCuts[i] = pCut;
778  }
779 // Abc_Print( 1, "%d ", Counter );
780 
781  // update the number of cuts
782  if ( pCutSet->nCuts < pCutSet->nCutsMax )
783  pCutSet->nCuts++;
784 }
Definition: if.h:275
char * pLutStruct
Definition: if.h:141
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
int fUseCofVars
Definition: if.h:135
int fEnableCheck75u
Definition: if.h:132
int fEnableCheck75
Definition: if.h:131
int fEnableCheck07
Definition: if.h:128
int fUseAndVars
Definition: if.h:136
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
int fUseDsd
Definition: if.h:133
If_Par_t * pPars
Definition: if.h:184
short nCuts
Definition: if.h:297
int fUseDsdTune
Definition: if.h:134
int fUserRecLib
Definition: if.h:124
static int If_ManSortCompare(If_Man_t *p, If_Cut_t *pC0, If_Cut_t *pC1)
Definition: ifCut.c:502
int fUseBat
Definition: if.h:126
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
static unsigned If_CutSuppMask ( If_Cut_t pCut)
inlinestatic

Definition at line 393 of file if.h.

393 { return (~(unsigned)0) >> (32-pCut->nLeaves); }
unsigned nLeaves
Definition: if.h:289
void If_CutTraverse ( If_Man_t p,
If_Obj_t pRoot,
If_Cut_t pCut,
Vec_Ptr_t vNodes 
)

Definition at line 565 of file ifUtil.c.

566 {
567  If_Obj_t * pLeaf;
568  int i;
569  // collect the internal nodes of the cut
570  Vec_PtrClear( vNodes );
571  If_CutForEachLeaf( p, pCut, pLeaf, i )
572  {
573  Vec_PtrPush( vNodes, pLeaf );
574  assert( pLeaf->fMark == 0 );
575  pLeaf->fMark = 1;
576  }
577  // collect other nodes
578  If_CutTraverse_rec( pRoot, vNodes );
579  // clean the mark
580  Vec_PtrForEachEntry( If_Obj_t *, vNodes, pLeaf, i )
581  pLeaf->fMark = 0;
582 }
Definition: if.h:303
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: if.h:474
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void If_CutTraverse_rec(If_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: ifUtil.c:553
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
unsigned fMark
Definition: if.h:310
static unsigned* If_CutTruth ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 422 of file if.h.

422 { return (unsigned *)If_CutTruthW(p, pCut); }
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
static int If_CutTruthIsCompl ( If_Cut_t pCut)
inlinestatic

Definition at line 418 of file if.h.

418 { assert( pCut->iCutFunc >= 0 ); return Abc_LitIsCompl(pCut->iCutFunc); }
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
#define assert(ex)
Definition: util_old.h:213
int iCutFunc
Definition: if.h:281
static int If_CutTruthLit ( If_Cut_t pCut)
inlinestatic

Definition at line 417 of file if.h.

417 { assert( pCut->iCutFunc >= 0 ); return pCut->iCutFunc; }
#define assert(ex)
Definition: util_old.h:213
int iCutFunc
Definition: if.h:281
static unsigned* If_CutTruthUR ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 420 of file if.h.

420 { return (unsigned *)If_CutTruthWR(p, pCut); }
static word * If_CutTruthWR(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:419
static word* If_CutTruthW ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 421 of file if.h.

421 { if ( p->vTtMem == NULL ) return NULL; assert( pCut->iCutFunc >= 0 ); Abc_TtCopy( p->puTempW, If_CutTruthWR(p, pCut), p->nTruth6Words[pCut->nLeaves], If_CutTruthIsCompl(pCut) ); return p->puTempW; }
int nTruth6Words[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:226
unsigned nLeaves
Definition: if.h:289
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:244
static int If_CutTruthIsCompl(If_Cut_t *pCut)
Definition: if.h:418
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
static word * If_CutTruthWR(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:419
word * puTempW
Definition: if.h:204
#define assert(ex)
Definition: util_old.h:213
int iCutFunc
Definition: if.h:281
static int If_CutTruthWords ( int  nVarsMax)
inlinestatic

Definition at line 394 of file if.h.

394 { return nVarsMax <= 5 ? 2 : (1 << (nVarsMax - 5)); }
static word* If_CutTruthWR ( If_Man_t p,
If_Cut_t pCut 
)
inlinestatic

Definition at line 419 of file if.h.

419 { return p->vTtMem ? Vec_MemReadEntry(p->vTtMem[pCut->nLeaves], Abc_Lit2Var(pCut->iCutFunc)) : NULL; }
unsigned nLeaves
Definition: if.h:289
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:244
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static word * Vec_MemReadEntry(Vec_Mem_t *p, int i)
Definition: vecMem.h:191
int iCutFunc
Definition: if.h:281
int If_CutVerifyCuts ( If_Set_t pCutSet,
int  fOrdered 
)

Definition at line 62 of file ifCut.c.

63 {
64  static int Count = 0;
65  If_Cut_t * pCut0, * pCut1;
66  int i, k, m, n, Value;
67  assert( pCutSet->nCuts > 0 );
68  for ( i = 0; i < pCutSet->nCuts; i++ )
69  {
70  pCut0 = pCutSet->ppCuts[i];
71  assert( pCut0->uSign == If_ObjCutSignCompute(pCut0) );
72  if ( fOrdered )
73  {
74  // check duplicates
75  for ( m = 1; m < (int)pCut0->nLeaves; m++ )
76  assert( pCut0->pLeaves[m-1] < pCut0->pLeaves[m] );
77  }
78  else
79  {
80  // check duplicates
81  for ( m = 0; m < (int)pCut0->nLeaves; m++ )
82  for ( n = m+1; n < (int)pCut0->nLeaves; n++ )
83  assert( pCut0->pLeaves[m] != pCut0->pLeaves[n] );
84  }
85  // check pairs
86  for ( k = 0; k < pCutSet->nCuts; k++ )
87  {
88  pCut1 = pCutSet->ppCuts[k];
89  if ( pCut0 == pCut1 )
90  continue;
91  Count++;
92  // check containments
93  Value = If_CutVerifyCut( pCut0, pCut1 );
94 // assert( Value == 0 );
95  if ( Value )
96  {
97  assert( pCut0->uSign == If_ObjCutSignCompute(pCut0) );
98  assert( pCut1->uSign == If_ObjCutSignCompute(pCut1) );
99  If_CutPrint( pCut0 );
100  If_CutPrint( pCut1 );
101  assert( 0 );
102  }
103  }
104  }
105  return 1;
106 }
unsigned nLeaves
Definition: if.h:289
Definition: if.h:275
int pLeaves[0]
Definition: if.h:290
static ABC_NAMESPACE_IMPL_START int If_CutVerifyCut(If_Cut_t *pBase, If_Cut_t *pCut)
DECLARATIONS ///.
Definition: ifCut.c:45
static unsigned If_ObjCutSignCompute(If_Cut_t *p)
Definition: if.h:403
short nCuts
Definition: if.h:297
void If_CutPrint(If_Cut_t *pCut)
Definition: ifCut.c:856
unsigned uSign
Definition: if.h:283
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
If_DsdMan_t* If_DsdManAlloc ( int  nVars,
int  nLutSize 
)

Definition at line 248 of file ifDsd.c.

249 {
250  If_DsdMan_t * p; int v;
251  char pFileName[10];
252  assert( nVars <= DAU_MAX_VAR );
253  sprintf( pFileName, "%02d.dsd", nVars );
254  p = ABC_CALLOC( If_DsdMan_t, 1 );
255  p->pStore = Abc_UtilStrsav( pFileName );
256  p->nVars = nVars;
257  p->LutSize = LutSize;
258  p->nWords = Abc_TtWordNum( nVars );
259  p->nBins = Abc_PrimeCudd( 100000 );
260  p->pBins = ABC_CALLOC( unsigned, p->nBins );
261  p->pMem = Mem_FlexStart();
262  Vec_PtrGrow( &p->vObjs, 10000 );
263  Vec_IntGrow( &p->vNexts, 10000 );
264  Vec_IntGrow( &p->vTruths, 10000 );
265  If_DsdObjAlloc( p, IF_DSD_CONST0, 0 );
266  If_DsdObjAlloc( p, IF_DSD_VAR, 0 )->nSupp = 1;
267  p->vTemp1 = Vec_IntAlloc( 32 );
268  p->vTemp2 = Vec_IntAlloc( 32 );
269  p->pTtElems = If_ManDsdTtElems();
270  for ( v = 3; v <= nVars; v++ )
271  {
272  p->vTtMem[v] = Vec_MemAlloc( Abc_TtWordNum(v), 12 );
273  Vec_MemHashAlloc( p->vTtMem[v], 10000 );
274  p->vTtDecs[v] = Vec_PtrAlloc( 1000 );
275  }
276 /*
277  p->pTtGia = Gia_ManStart( nVars );
278  Gia_ManHashAlloc( p->pTtGia );
279  for ( v = 0; v < nVars; v++ )
280  Gia_ManAppendCi( p->pTtGia );
281 */
282  for ( v = 2; v < nVars; v++ )
283  p->pSched[v] = Extra_GreyCodeSchedule( v );
284  if ( LutSize )
285  p->pSat = If_ManSatBuildXY( LutSize );
286  p->vCover = Vec_IntAlloc( 0 );
287  return p;
288 }
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:85
word ** pTtElems
Definition: ifDsd.c:84
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
Vec_Int_t * vCover
Definition: ifDsd.c:91
Vec_Int_t vTruths
Definition: ifDsd.c:81
int * Extra_GreyCodeSchedule(int n)
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrGrow(Vec_Ptr_t *p, int nCapMin)
Definition: vecPtr.h:430
static void Vec_MemHashAlloc(Vec_Mem_t *p, int nTableSize)
Definition: vecMem.h:305
Vec_Ptr_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:86
void * pSat
Definition: ifDsd.c:92
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
Mem_Flex_t * Mem_FlexStart()
Definition: mem.c:311
static Vec_Mem_t * Vec_MemAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: utilMem.c:70
If_DsdObj_t * If_DsdObjAlloc(If_DsdMan_t *p, int Type, int nFans)
Definition: ifDsd.c:231
int LutSize
Definition: ifDsd.c:74
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define DAU_MAX_VAR
INCLUDES ///.
Definition: dau.h:42
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
char * pStore
Definition: ifDsd.c:72
Vec_Int_t * vTemp1
Definition: ifDsd.c:82
int nBins
Definition: ifDsd.c:76
char * sprintf()
Vec_Int_t vNexts
Definition: ifDsd.c:80
void * If_ManSatBuildXY(int nLutSize)
DECLARATIONS ///.
Definition: ifSat.c:45
int nWords
Definition: ifDsd.c:75
unsigned nSupp
Definition: ifDsd.c:63
Vec_Int_t * vTemp2
Definition: ifDsd.c:83
int * pSched[IF_MAX_FUNC_LUTSIZE]
Definition: ifDsd.c:88
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int Abc_TtWordNum(int nVars)
Definition: utilTruth.h:169
static word ** If_ManDsdTtElems()
Definition: ifDsd.c:219
Mem_Flex_t * pMem
Definition: ifDsd.c:78
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
unsigned * pBins
Definition: ifDsd.c:77
int nVars
Definition: ifDsd.c:73
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void If_DsdManAllocIsops ( If_DsdMan_t p,
int  nLutSize 
)

Definition at line 289 of file ifDsd.c.

290 {
291  Vec_Int_t * vLevel;
292  int v, i, fCompl;
293  word * pTruth;
294  if ( p->vIsops[3] != NULL )
295  return;
296  if ( Vec_PtrSize(&p->vObjs) > 2 )
297  printf( "Warning: DSD manager is already started without ISOPs.\n" );
298  for ( v = 3; v <= nLutSize; v++ )
299  {
300  p->vIsops[v] = Vec_WecAlloc( 100 );
301  Vec_MemForEachEntry( p->vTtMem[v], pTruth, i )
302  {
303  vLevel = Vec_WecPushLevel( p->vIsops[v] );
304  fCompl = Kit_TruthIsop( (unsigned *)pTruth, v, p->vCover, 1 );
305  if ( fCompl >= 0 && Vec_IntSize(p->vCover) <= 8 )
306  {
307  Vec_IntGrow( vLevel, Vec_IntSize(p->vCover) );
308  Vec_IntAppend( vLevel, p->vCover );
309  if ( fCompl )
310  vLevel->nCap ^= (1<<16); // hack to remember complemented attribute
311  }
312  }
313  assert( Vec_WecSize(p->vIsops[v]) == Vec_MemEntryNum(p->vTtMem[v]) );
314  }
315 }
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:85
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
Vec_Int_t * vCover
Definition: ifDsd.c:91
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Vec_MemForEachEntry(p, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecMem.h:68
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
Vec_Wec_t * vIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:87
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
int If_DsdManCheckDec ( If_DsdMan_t p,
int  iDsd 
)

Definition at line 185 of file ifDsd.c.

186 {
187  return If_DsdVecObjMark( &p->vObjs, Abc_Lit2Var(iDsd) );
188 }
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int If_DsdVecObjMark(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:127
unsigned If_DsdManCheckXY ( If_DsdMan_t p,
int  iDsd,
int  LutSize,
int  fDerive,
unsigned  uMaskNot,
int  fHighEffort,
int  fVerbose 
)

Definition at line 1986 of file ifDsd.c.

1987 {
1988  unsigned uSet = If_DsdManCheckXY_int( p, iDsd, LutSize, fDerive, uMaskNot, fVerbose );
1989  if ( uSet == 0 && fHighEffort )
1990  {
1991 // abctime clk = Abc_Clock();
1992  int nVars = If_DsdVecLitSuppSize( &p->vObjs, iDsd );
1993  word * pRes = If_DsdManComputeTruth( p, iDsd, NULL );
1994  uSet = If_ManSatCheckXYall( p->pSat, LutSize, pRes, nVars, p->vTemp1 );
1995  if ( uSet )
1996  {
1997 // If_DsdManPrintOne( stdout, p, Abc_Lit2Var(iDsd), NULL, 1 );
1998 // Dau_DecPrintSet( uSet, nVars, 1 );
1999  }
2000 // p->timeCheck2 += Abc_Clock() - clk;
2001  }
2002  return uSet;
2003 }
static int If_DsdVecLitSuppSize(Vec_Ptr_t *p, int iLit)
Definition: ifDsd.c:123
void * pSat
Definition: ifDsd.c:92
unsigned If_ManSatCheckXYall(void *pSat, int nLutSize, word *pTruth, int nVars, Vec_Int_t *vLits)
Definition: ifSat.c:476
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
Vec_Int_t * vTemp1
Definition: ifDsd.c:82
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
word * If_DsdManComputeTruth(If_DsdMan_t *p, int iDsd, unsigned char *pPermLits)
Definition: ifDsd.c:1396
unsigned If_DsdManCheckXY_int(If_DsdMan_t *p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fVerbose)
Definition: ifDsd.c:1911
void If_DsdManCleanMarks ( If_DsdMan_t p,
int  fVerbose 
)

Definition at line 1224 of file ifDsd.c.

1225 {
1226  If_DsdObj_t * pObj;
1227  int i;
1228  ABC_FREE( p->pCellStr );
1229  Vec_WrdFreeP( &p->vPerms );
1230  If_DsdVecForEachObj( &p->vObjs, pObj, i )
1231  pObj->fMark = 0;
1232 }
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
char * pCellStr
Definition: ifDsd.c:93
static void Vec_WrdFreeP(Vec_Wrd_t **p)
Definition: vecWrd.h:277
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define If_DsdVecForEachObj(vVec, pObj, i)
Definition: ifDsd.c:131
void If_DsdManCleanOccur ( If_DsdMan_t p,
int  fVerbose 
)

Definition at line 1217 of file ifDsd.c.

1218 {
1219  If_DsdObj_t * pObj;
1220  int i;
1221  If_DsdVecForEachObj( &p->vObjs, pObj, i )
1222  pObj->Count = 0;
1223 }
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
#define If_DsdVecForEachObj(vVec, pObj, i)
Definition: ifDsd.c:131
int If_DsdManCompute ( If_DsdMan_t p,
word pTruth,
int  nLeaves,
unsigned char *  pPerm,
char *  pLutStruct 
)

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

Synopsis [Add the function to the DSD manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 2032 of file ifDsd.c.

2033 {
2034  word pCopy[DAU_MAX_WORD], * pRes;
2035  char pDsd[DAU_MAX_STR];
2036  int iDsd, nSizeNonDec, nSupp = 0;
2037  int nWords = Abc_TtWordNum(nLeaves);
2038 // abctime clk = 0;
2039  assert( nLeaves <= DAU_MAX_VAR );
2040  Abc_TtCopy( pCopy, pTruth, nWords, 0 );
2041 //clk = Abc_Clock();
2042  nSizeNonDec = Dau_DsdDecompose( pCopy, nLeaves, 0, 1, pDsd );
2043 //p->timeDsd += Abc_Clock() - clk;
2044  if ( nSizeNonDec > 0 )
2045  Abc_TtStretch6( pCopy, nSizeNonDec, p->nVars );
2046  memset( pPerm, 0xFF, nLeaves );
2047 //clk = Abc_Clock();
2048  iDsd = If_DsdManAddDsd( p, pDsd, pCopy, pPerm, &nSupp );
2049 //p->timeCanon += Abc_Clock() - clk;
2050  assert( nSupp == nLeaves );
2051  // verify the result
2052 //clk = Abc_Clock();
2053  pRes = If_DsdManComputeTruth( p, iDsd, pPerm );
2054 //p->timeVerify += Abc_Clock() - clk;
2055  if ( !Abc_TtEqual(pRes, pTruth, nWords) )
2056  {
2057 // If_DsdManPrint( p, NULL );
2058  printf( "\n" );
2059  printf( "Verification failed!\n" );
2060  printf( "%s\n", pDsd );
2061  Dau_DsdPrintFromTruth( pTruth, nLeaves );
2062  Dau_DsdPrintFromTruth( pRes, nLeaves );
2063  If_DsdManPrintOne( stdout, p, Abc_Lit2Var(iDsd), pPerm, 1 );
2064  printf( "\n" );
2065  }
2066  If_DsdVecObjIncRef( &p->vObjs, Abc_Lit2Var(iDsd) );
2067  assert( If_DsdVecLitSuppSize(&p->vObjs, iDsd) == nLeaves );
2068  return iDsd;
2069 }
char * memset()
static int If_DsdVecLitSuppSize(Vec_Ptr_t *p, int iLit)
Definition: ifDsd.c:123
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
static void If_DsdVecObjIncRef(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:125
void If_DsdManPrintOne(FILE *pFile, If_DsdMan_t *p, int iObjId, unsigned char *pPermLits, int fNewLine)
Definition: ifDsd.c:492
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition: dauDsd.c:1912
int nWords
Definition: abcNpn.c:127
#define DAU_MAX_STR
Definition: dau.h:43
static void Abc_TtCopy(word *pOut, word *pIn, int nWords, int fCompl)
Definition: utilTruth.h:221
int If_DsdManAddDsd(If_DsdMan_t *p, char *pDsd, word *pTruth, unsigned char *pPerm, int *pnSupp)
Definition: ifDsd.c:1687
#define DAU_MAX_VAR
INCLUDES ///.
Definition: dau.h:42
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TtStretch6(word *pInOut, int nVarS, int nVarB)
Definition: utilTruth.h:693
word * If_DsdManComputeTruth(If_DsdMan_t *p, int iDsd, unsigned char *pPermLits)
Definition: ifDsd.c:1396
static int pPerm[13719]
Definition: rwrTemp.c:32
#define DAU_MAX_WORD
Definition: dau.h:44
static int Abc_TtWordNum(int nVars)
Definition: utilTruth.h:169
static int Abc_TtEqual(word *pIn1, word *pIn2, int nWords)
Definition: utilTruth.h:269
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int nVars
Definition: ifDsd.c:73
#define assert(ex)
Definition: util_old.h:213
char* If_DsdManFileName ( If_DsdMan_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file ifDsd.c.

162 {
163  return p->pStore;
164 }
char * pStore
Definition: ifDsd.c:72
If_DsdMan_t* If_DsdManFilter ( If_DsdMan_t p,
int  Limit 
)

Definition at line 1263 of file ifDsd.c.

1264 {
1265  If_DsdMan_t * pNew = If_DsdManAlloc( p->nVars, p->LutSize );
1266  If_DsdObj_t * pObj;
1267  Vec_Int_t * vMap;
1268  int i;
1269  vMap = Vec_IntStartFull( Vec_PtrSize(&p->vObjs) );
1270  Vec_IntWriteEntry( vMap, 0, 0 );
1271  Vec_IntWriteEntry( vMap, 1, 1 );
1272  If_DsdVecForEachNode( &p->vObjs, pObj, i )
1273  if ( (int)pObj->Count >= Limit )
1274  If_DsdManFilter_rec( pNew, p, i, vMap );
1275  Vec_IntFree( vMap );
1276  return pNew;
1277 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
int LutSize
Definition: ifDsd.c:74
void If_DsdManFilter_rec(If_DsdMan_t *pNew, If_DsdMan_t *p, int i, Vec_Int_t *vMap)
Definition: ifDsd.c:1242
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
if(last==0)
Definition: sparse_int.h:34
int nVars
Definition: ifDsd.c:73
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define If_DsdVecForEachNode(vVec, pObj, i)
Definition: ifDsd.c:137
If_DsdMan_t * If_DsdManAlloc(int nVars, int LutSize)
Definition: ifDsd.c:248
void If_DsdManFree ( If_DsdMan_t p,
int  fVerbose 
)

Definition at line 316 of file ifDsd.c.

317 {
318  int v;
319 // If_DsdManDumpDsd( p );
320  if ( fVerbose )
321  If_DsdManPrint( p, NULL, 0, 0, 0, 0, 0 );
322  if ( fVerbose )
323  {
324  char FileName[10];
325  for ( v = 3; v <= p->nVars; v++ )
326  {
327  sprintf( FileName, "dumpdsd%02d", v );
328  Vec_MemDumpTruthTables( p->vTtMem[v], FileName, v );
329  }
330  }
331  for ( v = 2; v < p->nVars; v++ )
332  ABC_FREE( p->pSched[v] );
333  for ( v = 3; v <= p->nVars; v++ )
334  {
335  Vec_MemHashFree( p->vTtMem[v] );
336  Vec_MemFree( p->vTtMem[v] );
337  Vec_VecFree( (Vec_Vec_t *)(p->vTtDecs[v]) );
338  if ( p->vIsops[v] )
339  Vec_WecFree( p->vIsops[v] );
340  }
341  Vec_WrdFreeP( &p->vPerms );
342  Vec_IntFreeP( &p->vTemp1 );
343  Vec_IntFreeP( &p->vTemp2 );
344  ABC_FREE( p->vObjs.pArray );
345  ABC_FREE( p->vNexts.pArray );
346  ABC_FREE( p->vTruths.pArray );
347  Mem_FlexStop( p->pMem, 0 );
348  Gia_ManStopP( &p->pTtGia );
349  Vec_IntFreeP( &p->vCover );
350  If_ManSatUnbuild( p->pSat );
351  ABC_FREE( p->pCellStr );
352  ABC_FREE( p->pStore );
353  ABC_FREE( p->pBins );
354  ABC_FREE( p );
355 }
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:85
Gia_Man_t * pTtGia
Definition: ifDsd.c:90
Vec_Int_t * vCover
Definition: ifDsd.c:91
Vec_Int_t vTruths
Definition: ifDsd.c:81
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
void If_DsdManPrint(If_DsdMan_t *p, char *pFileName, int Number, int Support, int fOccurs, int fTtDump, int fVerbose)
Definition: ifDsd.c:684
static void Vec_WecFree(Vec_Wec_t *p)
Definition: vecWec.h:345
Vec_Ptr_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:86
char * pCellStr
Definition: ifDsd.c:93
Vec_Wec_t * vIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:87
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
static void Vec_WrdFreeP(Vec_Wrd_t **p)
Definition: vecWrd.h:277
void * pSat
Definition: ifDsd.c:92
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
char * pStore
Definition: ifDsd.c:72
Vec_Int_t * vTemp1
Definition: ifDsd.c:82
char * sprintf()
Vec_Int_t vNexts
Definition: ifDsd.c:80
void If_ManSatUnbuild(void *p)
Definition: ifSat.c:85
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static void Vec_MemDumpTruthTables(Vec_Mem_t *p, char *pName, int nLutSize)
Definition: vecMem.h:402
static void Vec_MemFree(Vec_Mem_t *p)
Definition: utilMem.c:93
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition: mem.c:343
Vec_Int_t * vTemp2
Definition: ifDsd.c:83
int * pSched[IF_MAX_FUNC_LUTSIZE]
Definition: ifDsd.c:88
#define ABC_FREE(obj)
Definition: abc_global.h:232
Mem_Flex_t * pMem
Definition: ifDsd.c:78
unsigned * pBins
Definition: ifDsd.c:77
int nVars
Definition: ifDsd.c:73
static void Vec_MemHashFree(Vec_Mem_t *p)
Definition: vecMem.h:311
char* If_DsdManGetCellStr ( If_DsdMan_t p)

Definition at line 203 of file ifDsd.c.

204 {
205  return p->pCellStr;
206 }
char * pCellStr
Definition: ifDsd.c:93
word If_DsdManGetFuncPerm ( If_DsdMan_t p,
int  iDsd 
)

Definition at line 199 of file ifDsd.c.

200 {
201  return p->vPerms ? Vec_WrdEntry(p->vPerms, Abc_Lit2Var(iDsd)) : 0;
202 }
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
void If_DsdManInvertMarks ( If_DsdMan_t p,
int  fVerbose 
)

Definition at line 1233 of file ifDsd.c.

1234 {
1235  If_DsdObj_t * pObj;
1236  int i;
1237  ABC_FREE( p->pCellStr );
1238  Vec_WrdFreeP( &p->vPerms );
1239  If_DsdVecForEachObj( &p->vObjs, pObj, i )
1240  pObj->fMark = !pObj->fMark;
1241 }
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
char * pCellStr
Definition: ifDsd.c:93
static void Vec_WrdFreeP(Vec_Wrd_t **p)
Definition: vecWrd.h:277
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define If_DsdVecForEachObj(vVec, pObj, i)
Definition: ifDsd.c:131
If_DsdMan_t* If_DsdManLoad ( char *  pFileName)

Definition at line 1086 of file ifDsd.c.

1087 {
1088  If_DsdMan_t * p;
1089  If_DsdObj_t * pObj;
1090  Vec_Int_t * vSets;
1091  char pBuffer[10];
1092  unsigned * pSpot;
1093  word * pTruth;
1094  int i, v, Num, Num2, RetValue;
1095  FILE * pFile = fopen( pFileName, "rb" );
1096  if ( pFile == NULL )
1097  {
1098  printf( "Reading DSD manager file \"%s\" has failed.\n", pFileName );
1099  return NULL;
1100  }
1101  RetValue = fread( pBuffer, 4, 1, pFile );
1102  if ( pBuffer[0] != 'd' && pBuffer[1] != 's' && pBuffer[2] != 'd' && pBuffer[3] != '0' )
1103  {
1104  printf( "Unrecognized format of file \"%s\".\n", pFileName );
1105  return NULL;
1106  }
1107  RetValue = fread( &Num, 4, 1, pFile );
1108  p = If_DsdManAlloc( Num, 0 );
1109  ABC_FREE( p->pStore );
1110  p->pStore = Abc_UtilStrsav( pFileName );
1111  RetValue = fread( &Num, 4, 1, pFile );
1112  p->LutSize = Num;
1113  p->pSat = If_ManSatBuildXY( p->LutSize );
1114  RetValue = fread( &Num, 4, 1, pFile );
1115  assert( Num >= 2 );
1116  Vec_PtrFillExtra( &p->vObjs, Num, NULL );
1117  Vec_IntFill( &p->vNexts, Num, 0 );
1118  Vec_IntFill( &p->vTruths, Num, -1 );
1119  p->nBins = Abc_PrimeCudd( 2*Num );
1120  p->pBins = ABC_REALLOC( unsigned, p->pBins, p->nBins );
1121  memset( p->pBins, 0, sizeof(unsigned) * p->nBins );
1122  for ( i = 2; i < Vec_PtrSize(&p->vObjs); i++ )
1123  {
1124  RetValue = fread( &Num, 4, 1, pFile );
1125  pObj = (If_DsdObj_t *)Mem_FlexEntryFetch( p->pMem, sizeof(word) * Num );
1126  RetValue = fread( pObj, sizeof(word)*Num, 1, pFile );
1127  Vec_PtrWriteEntry( &p->vObjs, i, pObj );
1128  if ( pObj->Type == IF_DSD_PRIME )
1129  {
1130  RetValue = fread( &Num, 4, 1, pFile );
1131  Vec_IntWriteEntry( &p->vTruths, i, Num );
1132  }
1133  pSpot = If_DsdObjHashLookup( p, pObj->Type, (int *)pObj->pFans, pObj->nFans, If_DsdObjTruthId(p, pObj) );
1134  assert( *pSpot == 0 );
1135  *pSpot = pObj->Id;
1136  }
1137  assert( p->nUniqueMisses == Vec_PtrSize(&p->vObjs) - 2 );
1138  p->nUniqueMisses = 0;
1139  pTruth = ABC_ALLOC( word, p->nWords );
1140  for ( v = 3; v <= p->nVars; v++ )
1141  {
1142  int nBytes = sizeof(word)*Vec_MemEntrySize(p->vTtMem[v]);
1143  RetValue = fread( &Num, 4, 1, pFile );
1144  for ( i = 0; i < Num; i++ )
1145  {
1146  RetValue = fread( pTruth, nBytes, 1, pFile );
1147  Vec_MemHashInsert( p->vTtMem[v], pTruth );
1148  }
1149  assert( Num == Vec_MemEntryNum(p->vTtMem[v]) );
1150  RetValue = fread( &Num2, 4, 1, pFile );
1151  for ( i = 0; i < Num2; i++ )
1152  {
1153  RetValue = fread( &Num, 4, 1, pFile );
1154  vSets = Vec_IntAlloc( Num );
1155  RetValue = fread( Vec_IntArray(vSets), sizeof(int)*Num, 1, pFile );
1156  vSets->nSize = Num;
1157  Vec_PtrPush( p->vTtDecs[v], vSets );
1158  }
1159  assert( Num2 == Vec_PtrSize(p->vTtDecs[v]) );
1160  }
1161  ABC_FREE( pTruth );
1162  RetValue = fread( &Num, 4, 1, pFile );
1163  if ( RetValue && Num )
1164  {
1165  p->vPerms = Vec_WrdStart( Num );
1166  RetValue = fread( Vec_WrdArray(p->vPerms), sizeof(word)*Num, 1, pFile );
1167  }
1168  RetValue = fread( &Num, 4, 1, pFile );
1169  if ( RetValue && Num )
1170  {
1171  p->pCellStr = ABC_CALLOC( char, Num + 1 );
1172  RetValue = fread( p->pCellStr, sizeof(char)*Num, 1, pFile );
1173  }
1174  fclose( pFile );
1175  return p;
1176 }
char * memset()
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:85
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
Vec_Int_t vTruths
Definition: ifDsd.c:81
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
Vec_Ptr_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:86
static void Vec_PtrFillExtra(Vec_Ptr_t *p, int nSize, void *Fill)
Definition: vecPtr.h:469
static int Vec_MemEntrySize(Vec_Mem_t *p)
Definition: vecMem.h:147
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
char * pCellStr
Definition: ifDsd.c:93
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void * pSat
Definition: ifDsd.c:92
static int If_DsdObjTruthId(If_DsdMan_t *p, If_DsdObj_t *pObj)
Definition: ifDsd.c:106
unsigned nFans
Definition: ifDsd.c:66
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition: mem.c:372
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
unsigned Type
Definition: ifDsd.c:62
int LutSize
Definition: ifDsd.c:74
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
unsigned * If_DsdObjHashLookup(If_DsdMan_t *p, int Type, int *pLits, int nLits, int truthId)
Definition: ifDsd.c:903
char * pStore
Definition: ifDsd.c:72
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
int nBins
Definition: ifDsd.c:76
Vec_Int_t vNexts
Definition: ifDsd.c:80
void * If_ManSatBuildXY(int nLutSize)
DECLARATIONS ///.
Definition: ifSat.c:45
int nWords
Definition: ifDsd.c:75
unsigned pFans[0]
Definition: ifDsd.c:67
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
#define ABC_FREE(obj)
Definition: abc_global.h:232
Mem_Flex_t * pMem
Definition: ifDsd.c:78
int nUniqueMisses
Definition: ifDsd.c:97
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
unsigned * pBins
Definition: ifDsd.c:77
int nVars
Definition: ifDsd.c:73
static int Vec_MemHashInsert(Vec_Mem_t *p, word *pEntry)
Definition: vecMem.h:351
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
unsigned Id
Definition: ifDsd.c:61
If_DsdMan_t * If_DsdManAlloc(int nVars, int LutSize)
Definition: ifDsd.c:248
int If_DsdManLutSize ( If_DsdMan_t p)

Definition at line 173 of file ifDsd.c.

174 {
175  return p->LutSize;
176 }
int LutSize
Definition: ifDsd.c:74
void If_DsdManMerge ( If_DsdMan_t p,
If_DsdMan_t pNew 
)

Definition at line 1177 of file ifDsd.c.

1178 {
1179  If_DsdObj_t * pObj;
1180  Vec_Int_t * vMap;
1181  int pFanins[DAU_MAX_VAR];
1182  int i, k, iFanin, Id;
1183  if ( p->nVars < pNew->nVars )
1184  {
1185  printf( "The number of variables should be the same or smaller.\n" );
1186  return;
1187  }
1188  if ( p->LutSize != pNew->LutSize )
1189  {
1190  printf( "LUT size should be the same.\n" );
1191  return;
1192  }
1193  if ( If_DsdManHasMarks(p) != If_DsdManHasMarks(pNew) )
1194  printf( "Warning! Old manager has %smarks while new manager has %smarks.\n",
1195  If_DsdManHasMarks(p) ? "" : "no ", If_DsdManHasMarks(pNew) ? "" : "no " );
1196  vMap = Vec_IntAlloc( Vec_PtrSize(&pNew->vObjs) );
1197  Vec_IntPush( vMap, 0 );
1198  Vec_IntPush( vMap, 1 );
1199  if ( p->vPerms && pNew->vPerms )
1200  Vec_WrdFillExtra( p->vPerms, Vec_PtrSize(&p->vObjs) + Vec_PtrSize(&pNew->vObjs), 0 );
1201  If_DsdVecForEachNode( &pNew->vObjs, pObj, i )
1202  {
1203  If_DsdObjForEachFaninLit( &pNew->vObjs, pObj, iFanin, k )
1204  pFanins[k] = Abc_Lit2LitV( Vec_IntArray(vMap), iFanin );
1205  Id = If_DsdObjFindOrAdd( p, pObj->Type, pFanins, pObj->nFans, pObj->Type == IF_DSD_PRIME ? If_DsdObjTruth(pNew, pObj) : NULL );
1206  if ( pObj->fMark )
1207  If_DsdVecObjSetMark( &p->vObjs, Id );
1208  if ( p->vPerms && pNew->vPerms && i < Vec_WrdSize(pNew->vPerms) )
1209  Vec_WrdFillExtra( p->vPerms, Id, Vec_WrdEntry(pNew->vPerms, i) );
1210  Vec_IntPush( vMap, Id );
1211  }
1212  assert( Vec_IntSize(vMap) == Vec_PtrSize(&pNew->vObjs) );
1213  Vec_IntFree( vMap );
1214  if ( p->vPerms && pNew->vPerms )
1215  Vec_WrdShrink( p->vPerms, Vec_PtrSize(&p->vObjs) );
1216 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Abc_Lit2LitV(int *pMap, int Lit)
Definition: abc_global.h:269
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static word * If_DsdObjTruth(If_DsdMan_t *p, If_DsdObj_t *pObj)
Definition: ifDsd.c:107
int LutSize
Definition: ifDsd.c:74
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define DAU_MAX_VAR
INCLUDES ///.
Definition: dau.h:42
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
static void Vec_WrdShrink(Vec_Wrd_t *p, int nSizeNew)
Definition: vecWrd.h:585
#define If_DsdObjForEachFaninLit(vVec, pObj, iLit, i)
Definition: ifDsd.c:141
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int If_DsdObjFindOrAdd(If_DsdMan_t *p, int Type, int *pLits, int nLits, word *pTruth)
Definition: ifDsd.c:976
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
int If_DsdManHasMarks(If_DsdMan_t *p)
Definition: ifDsd.c:415
int nVars
Definition: ifDsd.c:73
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define If_DsdVecForEachNode(vVec, pObj, i)
Definition: ifDsd.c:137
static void Vec_WrdFillExtra(Vec_Wrd_t *p, int nSize, word Fill)
Definition: vecWrd.h:509
static void If_DsdVecObjSetMark(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:128
int If_DsdManObjNum ( If_DsdMan_t p)

Definition at line 169 of file ifDsd.c.

170 {
171  return Vec_PtrSize( &p->vObjs );
172 }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
void If_DsdManPrint ( If_DsdMan_t p,
char *  pFileName,
int  Number,
int  Support,
int  fOccurs,
int  fTtDump,
int  fVerbose 
)

Definition at line 684 of file ifDsd.c.

685 {
686  If_DsdObj_t * pObj;
687  Vec_Int_t * vStructs, * vCounts;
688  int CountUsed = 0, CountNonDsd = 0, CountNonDsdStr = 0, CountMarked = 0, CountPrime = 0;
689  int i, v, * pPerm, DsdMax = 0, MemSizeTTs = 0, MemSizeDecs = 0;
690  FILE * pFile;
691  pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
692  if ( pFileName && pFile == NULL )
693  {
694  printf( "cannot open output file\n" );
695  return;
696  }
697  if ( fVerbose )
698  {
699  fprintf( pFile, "***** NOTATIONS USED BELOW *****\n" );
700  fprintf( pFile, "Support -- the support size\n" );
701  fprintf( pFile, "Obj -- the number of nodes in the DSD manager for each support size\n" );
702  fprintf( pFile, " (the constant node and the primary input node have no support)\n" );
703  fprintf( pFile, "ObjNDSD -- the number of prime nodes (that is, nodes whose function has no DSD)\n" );
704  fprintf( pFile, " (percentage is relative to the number of all nodes of that size)\n" );
705  fprintf( pFile, "NPNNDSD -- the number of different NPN classes of prime nodes\n" );
706  fprintf( pFile, " (Each NPN class may appear more than once. For example: F1 = 17(ab(cd))\n" );
707  fprintf( pFile, " and F2 = 17(ab[cd]) both have prime majority node (hex TT is 17),\n" );
708  fprintf( pFile, " but in one case the majority node is fed by AND, and in another by XOR.\n" );
709  fprintf( pFile, " These two majority nodes are different nodes in the DSD manager\n" );
710  fprintf( pFile, "Str -- the number of structures for each support size\n" );
711  fprintf( pFile, " (each structure is composed of one or more nodes)\n" );
712  fprintf( pFile, "StrNDSD -- the number of DSD structures containing at least one prime node\n" );
713  fprintf( pFile, "Marked -- the number of DSD structures matchable with the LUT structure (say, \"44\")\n" );
714  }
715  If_DsdVecForEachObj( &p->vObjs, pObj, i )
716  {
717  if ( If_DsdObjType(pObj) == IF_DSD_PRIME )
718  DsdMax = Abc_MaxInt( DsdMax, pObj->nFans );
719  CountPrime += If_DsdObjType(pObj) == IF_DSD_PRIME;
720  CountNonDsdStr += If_DsdManCheckNonDec_rec( p, pObj->Id );
721  CountUsed += ( If_DsdVecObjRef(&p->vObjs, pObj->Id) > 0 );
722  CountMarked += If_DsdVecObjMark( &p->vObjs, i );
723  }
724  for ( v = 3; v <= p->nVars; v++ )
725  {
726  CountNonDsd += Vec_MemEntryNum(p->vTtMem[v]);
727  MemSizeTTs += Vec_MemEntrySize(p->vTtMem[v]) * Vec_MemEntryNum(p->vTtMem[v]);
728  MemSizeDecs += (int)Vec_VecMemoryInt((Vec_Vec_t *)(p->vTtDecs[v]));
729  }
731  printf( "Number of inputs = %d. LUT size = %d. Marks = %s. NewAsUseless = %s. Bookmark = %d.\n",
732  p->nVars, p->LutSize, If_DsdManHasMarks(p)? "yes" : "no", p->fNewAsUseless? "yes" : "no", p->nObjsPrev );
733  if ( p->pCellStr )
734  printf( "Symbolic cell description: %s\n", p->pCellStr );
735  if ( p->pTtGia )
736  fprintf( pFile, "Non-DSD AIG nodes = %8d\n", Gia_ManAndNum(p->pTtGia) );
737  fprintf( pFile, "Unique table misses = %8d\n", p->nUniqueMisses );
738  fprintf( pFile, "Unique table hits = %8d\n", p->nUniqueHits );
739  fprintf( pFile, "Memory used for objects = %8.2f MB.\n", 1.0*Mem_FlexReadMemUsage(p->pMem)/(1<<20) );
740  fprintf( pFile, "Memory used for functions = %8.2f MB.\n", 8.0*(MemSizeTTs+sizeof(int)*Vec_IntCap(&p->vTruths))/(1<<20) );
741  fprintf( pFile, "Memory used for hash table = %8.2f MB.\n", 1.0*sizeof(int)*(p->nBins+Vec_IntCap(&p->vNexts))/(1<<20) );
742  fprintf( pFile, "Memory used for bound sets = %8.2f MB.\n", 1.0*MemSizeDecs/(1<<20) );
743  fprintf( pFile, "Memory used for array = %8.2f MB.\n", 1.0*sizeof(void *)*Vec_PtrCap(&p->vObjs)/(1<<20) );
744  if ( p->pTtGia )
745  fprintf( pFile, "Memory used for AIG = %8.2f MB.\n", 8.0*Gia_ManAndNum(p->pTtGia)/(1<<20) );
746  if ( p->timeDsd )
747  {
748  Abc_PrintTime( 1, "Time DSD ", p->timeDsd );
749  Abc_PrintTime( 1, "Time canon ", p->timeCanon-p->timeCheck );
750  Abc_PrintTime( 1, "Time check ", p->timeCheck );
751  Abc_PrintTime( 1, "Time check2", p->timeCheck2 );
752  Abc_PrintTime( 1, "Time verify", p->timeVerify );
753  }
754  if ( fOccurs )
755  If_DsdManPrintOccurs( stdout, p );
756 // If_DsdManHashProfile( p );
757  if ( fTtDump )
758  If_DsdManDumpDsd( p, Support );
759  if ( fTtDump )
760  If_DsdManDumpAll( p, Support );
761 // If_DsdManPrintDecs( stdout, p );
762  if ( !fVerbose )
763  return;
764  vStructs = Vec_IntAlloc( 1000 );
765  vCounts = Vec_IntAlloc( 1000 );
766  If_DsdVecForEachObj( &p->vObjs, pObj, i )
767  {
768  if ( Number && i % Number )
769  continue;
770  if ( Support && Support != If_DsdObjSuppSize(pObj) )
771  continue;
772  Vec_IntPush( vStructs, i );
773  Vec_IntPush( vCounts, -(int)pObj->Count );
774 // If_DsdManPrintOne( pFile, p, pObj->Id, NULL, 1 );
775  }
776 // fprintf( pFile, "\n" );
777  pPerm = Abc_MergeSortCost( Vec_IntArray(vCounts), Vec_IntSize(vCounts) );
778  for ( i = 0; i < Abc_MinInt(Vec_IntSize(vCounts), 20); i++ )
779  {
780  printf( "%2d : ", i+1 );
781  pObj = If_DsdVecObj( &p->vObjs, Vec_IntEntry(vStructs, pPerm[i]) );
782  If_DsdManPrintOne( pFile, p, pObj->Id, NULL, 1 );
783  }
784  ABC_FREE( pPerm );
785  Vec_IntFree( vStructs );
786  Vec_IntFree( vCounts );
787  if ( pFileName )
788  fclose( pFile );
789 }
abctime timeDsd
Definition: ifDsd.c:98
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:85
Gia_Man_t * pTtGia
Definition: ifDsd.c:90
abctime timeCheck2
Definition: ifDsd.c:101
Vec_Int_t vTruths
Definition: ifDsd.c:81
abctime timeCanon
Definition: ifDsd.c:99
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static double Vec_VecMemoryInt(Vec_Vec_t *p)
Definition: vecVec.h:304
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int nUniqueHits
Definition: ifDsd.c:96
Vec_Ptr_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:86
static int Vec_MemEntrySize(Vec_Mem_t *p)
Definition: vecMem.h:147
void If_DsdManPrintDistrib(If_DsdMan_t *p)
Definition: ifDsd.c:630
void If_DsdManPrintOccurs(FILE *pFile, If_DsdMan_t *p)
Definition: ifDsd.c:572
int fNewAsUseless
Definition: ifDsd.c:95
void If_DsdManPrintOne(FILE *pFile, If_DsdMan_t *p, int iObjId, unsigned char *pPermLits, int fNewLine)
Definition: ifDsd.c:492
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
char * pCellStr
Definition: ifDsd.c:93
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
void If_DsdManDumpDsd(If_DsdMan_t *p, int Support)
Definition: ifDsd.c:356
unsigned nFans
Definition: ifDsd.c:66
static int If_DsdObjType(If_DsdObj_t *pObj)
Definition: ifDsd.c:112
static int If_DsdVecObjRef(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:124
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int * Abc_MergeSortCost(int *pCosts, int nSize)
Definition: utilSort.c:238
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
abctime timeCheck
Definition: ifDsd.c:100
int LutSize
Definition: ifDsd.c:74
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
void If_DsdManDumpAll(If_DsdMan_t *p, int Support)
Definition: ifDsd.c:390
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
abctime timeVerify
Definition: ifDsd.c:102
int nBins
Definition: ifDsd.c:76
int If_DsdManCheckNonDec_rec(If_DsdMan_t *p, int Id)
Definition: ifDsd.c:453
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Int_t vNexts
Definition: ifDsd.c:80
static int Vec_IntCap(Vec_Int_t *p)
Definition: vecInt.h:368
static int pPerm[13719]
Definition: rwrTemp.c:32
static int Vec_PtrCap(Vec_Ptr_t *p)
Definition: vecPtr.h:311
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
Mem_Flex_t * pMem
Definition: ifDsd.c:78
int Mem_FlexReadMemUsage(Mem_Flex_t *p)
Definition: mem.c:445
int nUniqueMisses
Definition: ifDsd.c:97
static int If_DsdObjSuppSize(If_DsdObj_t *pObj)
Definition: ifDsd.c:114
int If_DsdManHasMarks(If_DsdMan_t *p)
Definition: ifDsd.c:415
static If_DsdObj_t * If_DsdVecObj(Vec_Ptr_t *p, int Id)
Definition: ifDsd.c:119
int nVars
Definition: ifDsd.c:73
#define If_DsdVecForEachObj(vVec, pObj, i)
Definition: ifDsd.c:131
unsigned Count
Definition: ifDsd.c:65
static int If_DsdVecObjMark(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:127
int nObjsPrev
Definition: ifDsd.c:94
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
unsigned Id
Definition: ifDsd.c:61
int If_DsdManReadMark ( If_DsdMan_t p,
int  iDsd 
)

Definition at line 189 of file ifDsd.c.

190 {
191  return If_DsdVecObjMark( &p->vObjs, Abc_Lit2Var(iDsd) );
192 }
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int If_DsdVecObjMark(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:127
void If_DsdManSave ( If_DsdMan_t p,
char *  pFileName 
)

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

Synopsis [Saving/loading DSD manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1032 of file ifDsd.c.

1033 {
1034  If_DsdObj_t * pObj;
1035  Vec_Int_t * vSets;
1036  char * pBuffer = "dsd0";
1037  word * pTruth;
1038  int i, v, Num;
1039  FILE * pFile = fopen( pFileName ? pFileName : p->pStore, "wb" );
1040  if ( pFile == NULL )
1041  {
1042  printf( "Writing DSD manager file \"%s\" has failed.\n", pFileName ? pFileName : p->pStore );
1043  return;
1044  }
1045  fwrite( pBuffer, 4, 1, pFile );
1046  Num = p->nVars;
1047  fwrite( &Num, 4, 1, pFile );
1048  Num = p->LutSize;
1049  fwrite( &Num, 4, 1, pFile );
1050  Num = Vec_PtrSize(&p->vObjs);
1051  fwrite( &Num, 4, 1, pFile );
1052  Vec_PtrForEachEntryStart( If_DsdObj_t *, &p->vObjs, pObj, i, 2 )
1053  {
1054  Num = If_DsdObjWordNum( pObj->nFans );
1055  fwrite( &Num, 4, 1, pFile );
1056  fwrite( pObj, sizeof(word)*Num, 1, pFile );
1057  if ( pObj->Type == IF_DSD_PRIME )
1058  fwrite( Vec_IntEntryP(&p->vTruths, i), 4, 1, pFile );
1059  }
1060  for ( v = 3; v <= p->nVars; v++ )
1061  {
1062  int nBytes = sizeof(word)*Vec_MemEntrySize(p->vTtMem[v]);
1063  Num = Vec_MemEntryNum(p->vTtMem[v]);
1064  fwrite( &Num, 4, 1, pFile );
1065  Vec_MemForEachEntry( p->vTtMem[v], pTruth, i )
1066  fwrite( pTruth, nBytes, 1, pFile );
1067  Num = Vec_PtrSize(p->vTtDecs[v]);
1068  fwrite( &Num, 4, 1, pFile );
1069  Vec_PtrForEachEntry( Vec_Int_t *, p->vTtDecs[v], vSets, i )
1070  {
1071  Num = Vec_IntSize(vSets);
1072  fwrite( &Num, 4, 1, pFile );
1073  fwrite( Vec_IntArray(vSets), sizeof(int)*Num, 1, pFile );
1074  }
1075  }
1076  Num = p->vPerms ? Vec_WrdSize(p->vPerms) : 0;
1077  fwrite( &Num, 4, 1, pFile );
1078  if ( Num )
1079  fwrite( Vec_WrdArray(p->vPerms), sizeof(word)*Num, 1, pFile );
1080  Num = p->pCellStr ? strlen(p->pCellStr) : 0;
1081  fwrite( &Num, 4, 1, pFile );
1082  if ( Num )
1083  fwrite( p->pCellStr, sizeof(char)*Num, 1, pFile );
1084  fclose( pFile );
1085 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: ifDsd.c:85
Vec_Int_t vTruths
Definition: ifDsd.c:81
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
Vec_Wrd_t * vPerms
Definition: ifDsd.c:89
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Vec_MemForEachEntry(p, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecMem.h:68
static int If_DsdObjWordNum(int nFans)
Definition: ifDsd.c:105
static int Vec_MemEntrySize(Vec_Mem_t *p)
Definition: vecMem.h:147
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
char * pCellStr
Definition: ifDsd.c:93
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
unsigned nFans
Definition: ifDsd.c:66
unsigned Type
Definition: ifDsd.c:62
int LutSize
Definition: ifDsd.c:74
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
char * pStore
Definition: ifDsd.c:72
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
int nVars
Definition: ifDsd.c:73
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
Definition: vecInt.h:417
int strlen()
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void If_DsdManSetLutSize ( If_DsdMan_t p,
int  nLutSize 
)

Definition at line 177 of file ifDsd.c.

178 {
179  p->LutSize = nLutSize;
180 }
int LutSize
Definition: ifDsd.c:74
void If_DsdManSetNewAsUseless ( If_DsdMan_t p)

Definition at line 193 of file ifDsd.c.

194 {
195  if ( p->nObjsPrev == 0 )
196  p->nObjsPrev = If_DsdManObjNum(p);
197  p->fNewAsUseless = 1;
198 }
int fNewAsUseless
Definition: ifDsd.c:95
int If_DsdManObjNum(If_DsdMan_t *p)
Definition: ifDsd.c:169
int nObjsPrev
Definition: ifDsd.c:94
int If_DsdManSuppSize ( If_DsdMan_t p,
int  iDsd 
)

Definition at line 181 of file ifDsd.c.

182 {
183  return If_DsdVecLitSuppSize( &p->vObjs, iDsd );
184 }
static int If_DsdVecLitSuppSize(Vec_Ptr_t *p, int iLit)
Definition: ifDsd.c:123
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
void If_DsdManTune ( If_DsdMan_t p,
int  LutSize,
int  fFast,
int  fAdd,
int  fSpec,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2377 of file ifDsd.c.

2378 {
2379  ProgressBar * pProgress = NULL;
2380  sat_solver * pSat = NULL;
2381  If_DsdObj_t * pObj;
2382  Vec_Int_t * vLits;
2383  int i, Value, nVars;
2384  word * pTruth;
2385  if ( !fAdd || !LutSize )
2386  If_DsdVecForEachObj( &p->vObjs, pObj, i )
2387  pObj->fMark = 0;
2388  if ( LutSize == 0 )
2389  return;
2390  vLits = Vec_IntAlloc( 1000 );
2391  pSat = (sat_solver *)If_ManSatBuildXY( LutSize );
2392  pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(&p->vObjs) );
2393  If_DsdVecForEachObj( &p->vObjs, pObj, i )
2394  {
2395  Extra_ProgressBarUpdate( pProgress, i, NULL );
2396  nVars = If_DsdObjSuppSize(pObj);
2397  if ( nVars <= LutSize )
2398  continue;
2399  if ( fAdd && !pObj->fMark )
2400  continue;
2401  pObj->fMark = 0;
2402  if ( If_DsdManCheckXY(p, Abc_Var2Lit(i, 0), LutSize, 0, 0, 0, 0) )
2403  continue;
2404  if ( fFast )
2405  Value = 0;
2406  else
2407  {
2408  pTruth = If_DsdManComputeTruth( p, Abc_Var2Lit(i, 0), NULL );
2409  Value = If_ManSatCheckXYall( pSat, LutSize, pTruth, nVars, vLits );
2410  }
2411  if ( Value )
2412  continue;
2413  If_DsdVecObjSetMark( &p->vObjs, i );
2414  }
2415  Extra_ProgressBarStop( pProgress );
2416  If_ManSatUnbuild( pSat );
2417  Vec_IntFree( vLits );
2418  if ( fVerbose )
2419  If_DsdManPrintDistrib( p );
2420 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
void If_DsdManPrintDistrib(If_DsdMan_t *p)
Definition: ifDsd.c:630
unsigned If_DsdManCheckXY(If_DsdMan_t *p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose)
Definition: ifDsd.c:1986
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
DECLARATIONS ///.
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
unsigned If_ManSatCheckXYall(void *pSat, int nLutSize, word *pTruth, int nVars, Vec_Int_t *vLits)
Definition: ifSat.c:476
Vec_Ptr_t vObjs
Definition: ifDsd.c:79
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
word * If_DsdManComputeTruth(If_DsdMan_t *p, int iDsd, unsigned char *pPermLits)
Definition: ifDsd.c:1396
void * If_ManSatBuildXY(int nLutSize)
DECLARATIONS ///.
Definition: ifSat.c:45
void If_ManSatUnbuild(void *p)
Definition: ifSat.c:85
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static int If_DsdObjSuppSize(If_DsdObj_t *pObj)
Definition: ifDsd.c:114
#define If_DsdVecForEachObj(vVec, pObj, i)
Definition: ifDsd.c:131
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void If_DsdVecObjSetMark(Vec_Ptr_t *p, int iObj)
Definition: ifDsd.c:128
int If_DsdManVarNum ( If_DsdMan_t p)

Definition at line 165 of file ifDsd.c.

166 {
167  return p->nVars;
168 }
int nVars
Definition: ifDsd.c:73
static int If_IsComplement ( If_Obj_t p)
inlinestatic

Definition at line 358 of file if.h.

358 { return (int )(((ABC_PTRUINT_T)p) & 01); }
void If_LibBoxAdd ( If_LibBox_t p,
If_Box_t pBox 
)

Definition at line 136 of file ifLibBox.c.

137 {
138  if ( pBox->Id >= Vec_PtrSize(p->vBoxes) )
139  Vec_PtrFillExtra( p->vBoxes, 2 * pBox->Id + 10, NULL );
140  assert( Vec_PtrEntry( p->vBoxes, pBox->Id ) == NULL );
141  Vec_PtrWriteEntry( p->vBoxes, pBox->Id, pBox );
142 }
static void Vec_PtrFillExtra(Vec_Ptr_t *p, int nSize, void *Fill)
Definition: vecPtr.h:469
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t * vBoxes
Definition: if.h:352
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int Id
Definition: if.h:344
#define assert(ex)
Definition: util_old.h:213
If_Box_t* If_LibBoxFindBox ( If_LibBox_t p,
char *  pName 
)

Definition at line 125 of file ifLibBox.c.

126 {
127  If_Box_t * pBox;
128  int i;
129  if ( p == NULL )
130  return NULL;
131  If_LibBoxForEachBox( p, pBox, i )
132  if ( !strcmp(pBox->pName, pName) )
133  return pBox;
134  return NULL;
135 }
#define If_LibBoxForEachBox(p, pBox, i)
DECLARATIONS ///.
Definition: ifLibBox.c:31
int strcmp()
if(last==0)
Definition: sparse_int.h:34
Definition: if.h:337
void If_LibBoxFree ( If_LibBox_t p)

Definition at line 98 of file ifLibBox.c.

99 {
100  If_Box_t * pBox;
101  int i;
102  if ( p == NULL )
103  return;
104  If_LibBoxForEachBox( p, pBox, i )
105  If_BoxFree( pBox );
106  Vec_PtrFree( p->vBoxes );
107  ABC_FREE( p );
108 }
void If_BoxFree(If_Box_t *p)
Definition: ifLibBox.c:68
#define If_LibBoxForEachBox(p, pBox, i)
DECLARATIONS ///.
Definition: ifLibBox.c:31
Definition: if.h:337
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int If_LibBoxLoad ( char *  pFileName)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 375 of file ifLibBox.c.

376 {
377  FILE * pFile;
378  If_LibBox_t * pLib;
379  char * pFileNameOther;
380  // check if library can be read
381  pFileNameOther = Extra_FileNameGenericAppend( pFileName, ".cdl" );
382  pFile = fopen( pFileNameOther, "r" );
383  if ( pFile == NULL )
384  return 0;
385  fclose( pFile );
386  // read library
387  pLib = If_LibBoxRead2( pFileNameOther );
388  // replace the current library
390  Abc_FrameSetLibBox( pLib );
391  return 1;
392 }
ABC_DLL void * Abc_FrameReadLibBox()
Definition: mainFrame.c:55
void If_LibBoxFree(If_LibBox_t *p)
Definition: ifLibBox.c:98
ABC_DLL void Abc_FrameSetLibBox(void *pLib)
Definition: mainFrame.c:81
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
If_LibBox_t * If_LibBoxRead2(char *pFileName)
Definition: ifLibBox.c:155
void If_LibBoxPrint ( FILE *  pFile,
If_LibBox_t p 
)

Definition at line 334 of file ifLibBox.c.

335 {
336  If_Box_t * pBox;
337  int i, j, k;
338  fprintf( pFile, "# Box library written by ABC on %s.\n", Extra_TimeStamp() );
339  fprintf( pFile, "# <Name> <ID> <Type> <I> <O>\n" );
340  If_LibBoxForEachBox( p, pBox, i )
341  {
342  fprintf( pFile, "%s %d %d %d %d\n", pBox->pName, pBox->Id, !pBox->fBlack, pBox->nPis, pBox->nPos );
343  for ( j = 0; j < pBox->nPos; j++, printf("\n") )
344  for ( k = 0; k < pBox->nPis; k++ )
345  if ( pBox->pDelays[j * pBox->nPis + k] == -ABC_INFINITY )
346  fprintf( pFile, " - " );
347  else
348  fprintf( pFile, "%5d ", pBox->pDelays[j * pBox->nPis + k] );
349  }
350 }
char fBlack
Definition: if.h:341
int * pDelays
Definition: if.h:347
#define If_LibBoxForEachBox(p, pBox, i)
DECLARATIONS ///.
Definition: ifLibBox.c:31
char * pName
Definition: if.h:339
int nPis
Definition: if.h:345
Definition: if.h:337
char * Extra_TimeStamp()
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
int Id
Definition: if.h:344
int nPos
Definition: if.h:346
If_LibBox_t* If_LibBoxRead ( char *  pFileName)

Definition at line 273 of file ifLibBox.c.

274 {
275  FILE * pFile;
276  If_LibBox_t * p;
277  If_Box_t * pBox;
278  char * pToken, * pName;
279  int i, Id, fBlack, nPis, nPos;
280  pFile = fopen( pFileName, "rb" );
281  if ( pFile == NULL )
282  {
283  printf( "Cannot open file \"%s\".\n", pFileName );
284  return NULL;
285  }
286  // get the library name
287  pToken = If_LibBoxGetToken( pFile );
288  if ( pToken == NULL )
289  {
290  fclose( pFile );
291  printf( "Cannot read library name from file \"%s\".\n", pFileName );
292  return NULL;
293  }
294  if ( pToken[0] == '.' )
295  {
296  fclose( pFile );
297  printf( "Wrong box format. Please try \"read_box -e\".\n" );
298  return NULL;
299  }
300 
301  // create library
302  p = If_LibBoxStart();
303  while ( pToken )
304  {
305  // save name
306  pName = Abc_UtilStrsav(pToken);
307  // save ID
308  pToken = If_LibBoxGetToken( pFile );
309  Id = atoi( pToken );
310  // save white/black
311  pToken = If_LibBoxGetToken( pFile );
312  fBlack = !atoi( pToken );
313  // save PIs
314  pToken = If_LibBoxGetToken( pFile );
315  nPis = atoi( pToken );
316  // save POs
317  pToken = If_LibBoxGetToken( pFile );
318  nPos = atoi( pToken );
319  // create box
320  pBox = If_BoxStart( pName, Id, nPis, nPos, 0, fBlack, 0 );
321  If_LibBoxAdd( p, pBox );
322  // read the table
323  for ( i = 0; i < nPis * nPos; i++ )
324  {
325  pToken = If_LibBoxGetToken( pFile );
326  pBox->pDelays[i] = (pToken[0] == '-') ? -ABC_INFINITY : atoi(pToken);
327  }
328  // extract next name
329  pToken = If_LibBoxGetToken( pFile );
330  }
331  fclose( pFile );
332  return p;
333 }
int * pDelays
Definition: if.h:347
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void If_LibBoxAdd(If_LibBox_t *p, If_Box_t *pBox)
Definition: ifLibBox.c:136
Definition: if.h:337
char * If_LibBoxGetToken(FILE *pFile)
Definition: ifLibBox.c:250
If_LibBox_t * If_LibBoxStart()
Definition: ifLibBox.c:86
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
If_Box_t * If_BoxStart(char *pName, int Id, int nPis, int nPos, int fSeq, int fBlack, int fOuter)
FUNCTION DEFINITIONS ///.
Definition: ifLibBox.c:49
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
If_LibBox_t* If_LibBoxRead2 ( char *  pFileName)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file ifLibBox.c.

156 {
157  int nSize = 100000;
158  char * pBuffer;
159  FILE * pFile;
160  If_LibBox_t * p = NULL;
161  If_Box_t * pBox = NULL;
162  char * pToken, * pName;
163  int fSeq, fBlack, fOuter;
164  int i, Id, nPis, nPos;
165  pFile = fopen( pFileName, "rb" );
166  if ( pFile == NULL )
167  {
168  printf( "Cannot open file \"%s\".\n", pFileName );
169  return NULL;
170  }
171  // read lines
172  nPis = nPos = 0;
173  pBuffer = ABC_ALLOC( char, nSize );
174  while ( fgets( pBuffer, nSize, pFile ) )
175  {
176  pToken = strtok( pBuffer, " \n\r\t" );
177  if ( pToken == NULL )
178  continue;
179  if ( pToken[0] == '.' )
180  {
181  if ( !strcmp(pToken, ".box") )
182  {
183  // save ID
184  pToken = strtok( NULL, " \n\r\t" );
185  Id = atoi( pToken );
186  // save name
187  pToken = strtok( NULL, " \n\r\t" );
188  pName = Abc_UtilStrsav(pToken);
189  // save PIs
190  pToken = strtok( NULL, " \n\r\t" );
191  nPis = atoi( pToken );
192  // save POs
193  pToken = strtok( NULL, " \n\r\t" );
194  nPos = atoi( pToken );
195  // save attributes
196  fSeq = fBlack = fOuter = 0;
197  pToken = strtok( NULL, " \n\r\t" );
198  while ( pToken )
199  {
200  if ( !strcmp(pToken, "seq") )
201  fSeq = 1;
202  else if ( !strcmp(pToken, "black") )
203  fBlack = 1;
204  else if ( !strcmp(pToken, "outer") )
205  fOuter = 1;
206  else assert( !strcmp(pToken, "comb") || !strcmp(pToken, "white") || !strcmp(pToken, "inner") );
207  pToken = strtok( NULL, " \n\r\t" );
208  }
209  // create library
210  if ( p == NULL )
211  p = If_LibBoxStart();
212  // create box
213  pBox = If_BoxStart( pName, Id, nPis, nPos, fSeq, fBlack, fOuter );
214  If_LibBoxAdd( p, pBox );
215  }
216  continue;
217  }
218  // read the table
219  assert( nPis > 0 && nPos > 0 );
220  for ( i = 0; i < nPis * nPos; i++ )
221  {
222  while ( pToken == NULL )
223  {
224  if ( fgets( pBuffer, nSize, pFile ) == NULL )
225  { printf( "The table does not have enough entries.\n" ); fflush(stdout); assert( 0 ); }
226  pToken = strtok( pBuffer, " \n\r\t" );
227  }
228  pBox->pDelays[i] = (pToken[0] == '-') ? -1 : atoi(pToken);
229  pToken = strtok( NULL, " \n\r\t" );
230  }
231  pBox = NULL;
232  }
233  ABC_FREE( pBuffer );
234  fclose( pFile );
235  return p;
236 }
int * pDelays
Definition: if.h:347
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void If_LibBoxAdd(If_LibBox_t *p, If_Box_t *pBox)
Definition: ifLibBox.c:136
char * strtok()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int strcmp()
Definition: if.h:337
#define ABC_FREE(obj)
Definition: abc_global.h:232
If_LibBox_t * If_LibBoxStart()
Definition: ifLibBox.c:86
#define assert(ex)
Definition: util_old.h:213
If_Box_t * If_BoxStart(char *pName, int Id, int nPis, int nPos, int fSeq, int fBlack, int fOuter)
FUNCTION DEFINITIONS ///.
Definition: ifLibBox.c:49
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
If_Box_t* If_LibBoxReadBox ( If_LibBox_t p,
int  Id 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file ifLibBox.c.

122 {
123  return (If_Box_t *)Vec_PtrEntry( p->vBoxes, Id );
124 }
Vec_Ptr_t * vBoxes
Definition: if.h:352
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Definition: if.h:337
If_LibBox_t* If_LibBoxStart ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file ifLibBox.c.

87 {
88  If_LibBox_t * p;
89  p = ABC_CALLOC( If_LibBox_t, 1 );
90  p->vBoxes = Vec_PtrAlloc( 100 );
91  return p;
92 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vBoxes
Definition: if.h:352
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void If_LibBoxWrite ( char *  pFileName,
If_LibBox_t p 
)

Definition at line 351 of file ifLibBox.c.

352 {
353  FILE * pFile;
354  pFile = fopen( pFileName, "wb" );
355  if ( pFile == NULL )
356  {
357  printf( "Cannot open file \"%s\".\n", pFileName );
358  return;
359  }
360  If_LibBoxPrint( pFile, p );
361  fclose( pFile );
362 }
void If_LibBoxPrint(FILE *pFile, If_LibBox_t *p)
Definition: ifLibBox.c:334
int If_LibLutDelaysAreDifferent ( If_LibLut_t pLutLib)

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

Synopsis [Returns 1 if the delays are discrete.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file ifLibLut.c.

249 {
250  int i, k;
251  float Delay = pLutLib->pLutDelays[1][0];
252  if ( pLutLib->fVarPinDelays )
253  {
254  for ( i = 2; i <= pLutLib->LutMax; i++ )
255  for ( k = 0; k < i; k++ )
256  if ( pLutLib->pLutDelays[i][k] != Delay )
257  return 1;
258  }
259  else
260  {
261  for ( i = 2; i <= pLutLib->LutMax; i++ )
262  if ( pLutLib->pLutDelays[i][0] != Delay )
263  return 1;
264  }
265  return 0;
266 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
int If_LibLutDelaysAreDiscrete ( If_LibLut_t pLutLib)

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

Synopsis [Returns 1 if the delays are discrete.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file ifLibLut.c.

225 {
226  float Delay;
227  int i;
228  for ( i = 1; i <= pLutLib->LutMax; i++ )
229  {
230  Delay = pLutLib->pLutDelays[i][0];
231  if ( ((float)((int)Delay)) != Delay )
232  return 0;
233  }
234  return 1;
235 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
If_LibLut_t* If_LibLutDup ( If_LibLut_t p)

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

Synopsis [Duplicates the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file ifLibLut.c.

154 {
155  If_LibLut_t * pNew;
156  pNew = ABC_ALLOC( If_LibLut_t, 1 );
157  *pNew = *p;
158  pNew->pName = If_UtilStrsav( pNew->pName );
159  return pNew;
160 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pName
Definition: if.h:172
static ABC_NAMESPACE_IMPL_START char * If_UtilStrsav(char *s)
DECLARATIONS ///.
Definition: ifLibLut.c:30
float If_LibLutFastestPinDelay ( If_LibLut_t p)

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

Synopsis [Gets the delay of the fastest pin.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file ifLibLut.c.

320 {
321  return !p? 1.0 : p->pLutDelays[p->LutMax][0];
322 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
void If_LibLutFree ( If_LibLut_t pLutLib)

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

Synopsis [Frees the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file ifLibLut.c.

174 {
175  if ( pLutLib == NULL )
176  return;
177  ABC_FREE( pLutLib->pName );
178  ABC_FREE( pLutLib );
179 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * pName
Definition: if.h:172
void If_LibLutPrint ( If_LibLut_t pLutLib)

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

Synopsis [Prints the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file ifLibLut.c.

194 {
195  int i, k;
196  Abc_Print( 1, "# The area/delay of k-variable LUTs:\n" );
197  Abc_Print( 1, "# k area delay\n" );
198  if ( pLutLib->fVarPinDelays )
199  {
200  for ( i = 1; i <= pLutLib->LutMax; i++ )
201  {
202  Abc_Print( 1, "%d %7.2f ", i, pLutLib->pLutAreas[i] );
203  for ( k = 0; k < i; k++ )
204  Abc_Print( 1, " %7.2f", pLutLib->pLutDelays[i][k] );
205  Abc_Print( 1, "\n" );
206  }
207  }
208  else
209  for ( i = 1; i <= pLutLib->LutMax; i++ )
210  Abc_Print( 1, "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
211 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
float pLutAreas[IF_MAX_LUTSIZE+1]
Definition: if.h:175
If_LibLut_t* If_LibLutRead ( char *  FileName)

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the description of LUTs from the LUT library file.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ifLibLut.c.

48 {
49  char pBuffer[1000], * pToken;
50  If_LibLut_t * p;
51  FILE * pFile;
52  int i, k;
53 
54  pFile = fopen( FileName, "r" );
55  if ( pFile == NULL )
56  {
57  Abc_Print( -1, "Cannot open LUT library file \"%s\".\n", FileName );
58  return NULL;
59  }
60 
61  p = ABC_ALLOC( If_LibLut_t, 1 );
62  memset( p, 0, sizeof(If_LibLut_t) );
63  p->pName = If_UtilStrsav( FileName );
64 
65  i = 1;
66  while ( fgets( pBuffer, 1000, pFile ) != NULL )
67  {
68  pToken = strtok( pBuffer, " \t\n" );
69  if ( pToken == NULL )
70  continue;
71  if ( pToken[0] == '#' )
72  continue;
73  if ( i != atoi(pToken) )
74  {
75  Abc_Print( 1, "Error in the LUT library file \"%s\".\n", FileName );
76  ABC_FREE( p->pName );
77  ABC_FREE( p );
78  return NULL;
79  }
80 
81  // read area
82  pToken = strtok( NULL, " \t\n" );
83  p->pLutAreas[i] = (float)atof(pToken);
84 
85  // read delays
86  k = 0;
87  while ( (pToken = strtok( NULL, " \t\n" )) )
88  p->pLutDelays[i][k++] = (float)atof(pToken);
89 
90  // check for out-of-bound
91  if ( k > i )
92  {
93  ABC_FREE( p->pName );
94  ABC_FREE( p );
95  Abc_Print( 1, "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
96  return NULL;
97  }
98 
99  // check if var delays are specified
100  if ( k > 1 )
101  p->fVarPinDelays = 1;
102 
103  if ( i == IF_MAX_LUTSIZE )
104  {
105  ABC_FREE( p->pName );
106  ABC_FREE( p );
107  Abc_Print( 1, "Skipping LUTs of size more than %d.\n", i );
108  return NULL;
109  }
110  i++;
111  }
112  p->LutMax = i-1;
113 
114  // check the library
115  if ( p->fVarPinDelays )
116  {
117  for ( i = 1; i <= p->LutMax; i++ )
118  for ( k = 0; k < i; k++ )
119  {
120  if ( p->pLutDelays[i][k] <= 0.0 )
121  Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
122  k, i, p->pLutDelays[i][k] );
123  if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
124  Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
125  k-1, i, p->pLutDelays[i][k-1],
126  k, i, p->pLutDelays[i][k] );
127  }
128  }
129  else
130  {
131  for ( i = 1; i <= p->LutMax; i++ )
132  {
133  if ( p->pLutDelays[i][0] <= 0.0 )
134  Abc_Print( 0, "LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
135  i, p->pLutDelays[i][0] );
136  }
137  }
138 
139  return p;
140 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int LutMax
Definition: if.h:173
char * strtok()
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int fVarPinDelays
Definition: if.h:174
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
double atof()
#define ABC_FREE(obj)
Definition: abc_global.h:232
float pLutAreas[IF_MAX_LUTSIZE+1]
Definition: if.h:175
char * pName
Definition: if.h:172
static ABC_NAMESPACE_IMPL_START char * If_UtilStrsav(char *s)
DECLARATIONS ///.
Definition: ifLibLut.c:30
If_LibLut_t* If_LibLutSetSimple ( int  nLutSize)

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

Synopsis [Sets simple LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file ifLibLut.c.

280 {
281  If_LibLut_t s_LutLib10= { "lutlib",10, 0, {0,1,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
282  If_LibLut_t s_LutLib9 = { "lutlib", 9, 0, {0,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
283  If_LibLut_t s_LutLib8 = { "lutlib", 8, 0, {0,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1}} };
284  If_LibLut_t s_LutLib7 = { "lutlib", 7, 0, {0,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1}} };
285  If_LibLut_t s_LutLib6 = { "lutlib", 6, 0, {0,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1}} };
286  If_LibLut_t s_LutLib5 = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} };
287  If_LibLut_t s_LutLib4 = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
288  If_LibLut_t s_LutLib3 = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} };
289  If_LibLut_t * pLutLib;
290  assert( nLutSize >= 3 && nLutSize <= 10 );
291  switch ( nLutSize )
292  {
293  case 3: pLutLib = &s_LutLib3; break;
294  case 4: pLutLib = &s_LutLib4; break;
295  case 5: pLutLib = &s_LutLib5; break;
296  case 6: pLutLib = &s_LutLib6; break;
297  case 7: pLutLib = &s_LutLib7; break;
298  case 8: pLutLib = &s_LutLib8; break;
299  case 9: pLutLib = &s_LutLib9; break;
300  case 10: pLutLib = &s_LutLib10; break;
301  default: pLutLib = NULL; break;
302  }
303  if ( pLutLib == NULL )
304  return NULL;
305  return If_LibLutDup(pLutLib);
306 }
If_LibLut_t * If_LibLutDup(If_LibLut_t *p)
Definition: ifLibLut.c:153
#define assert(ex)
Definition: util_old.h:213
float If_LibLutSlowestPinDelay ( If_LibLut_t p)

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

Synopsis [Gets the delay of the slowest pin.]

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file ifLibLut.c.

336 {
337  return !p? 1.0 : (p->fVarPinDelays? p->pLutDelays[p->LutMax][p->LutMax-1]: p->pLutDelays[p->LutMax][0]);
338 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
static int If_ManAndNum ( If_Man_t p)
inlinestatic

Definition at line 362 of file if.h.

362 { return p->nObjs[IF_AND]; }
Definition: if.h:68
int nObjs[IF_VOID]
Definition: if.h:192
static If_Obj_t* If_ManCi ( If_Man_t p,
int  i 
)
inlinestatic

Definition at line 366 of file if.h.

366 { return (If_Obj_t *)Vec_PtrEntry( p->vCis, i ); }
Definition: if.h:303
Vec_Ptr_t * vCis
Definition: if.h:187
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int If_ManCiNum ( If_Man_t p)
inlinestatic

Definition at line 360 of file if.h.

360 { return p->nObjs[IF_CI]; }
Definition: if.h:66
int nObjs[IF_VOID]
Definition: if.h:192
void If_ManCleanCutData ( If_Man_t p)

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

Synopsis [Sets all the cut data to NULL.]

Description []

SideEffects []

SeeAlso []

Definition at line 64 of file ifUtil.c.

65 {
66  If_Obj_t * pObj;
67  int i;
68  If_ManForEachObj( p, pObj, i )
69  If_CutSetData( If_ObjCutBest(pObj), NULL );
70 }
Definition: if.h:303
static void If_CutSetData(If_Cut_t *pCut, void *pData)
Definition: if.h:412
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
void If_ManCleanMarkV ( If_Man_t p)

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

Synopsis [Sets all visited marks to 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file ifUtil.c.

84 {
85  If_Obj_t * pObj;
86  int i;
87  If_ManForEachObj( p, pObj, i )
88  pObj->fVisit = 0;
89 }
Definition: if.h:303
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
void If_ManCleanNodeCopy ( If_Man_t p)

DECLARATIONS ///.

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

FileName [ifUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [Various utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id:
ifUtil.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

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

Synopsis [Sets all the node copy to NULL.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ifUtil.c.

46 {
47  If_Obj_t * pObj;
48  int i;
49  If_ManForEachObj( p, pObj, i )
50  If_ObjSetCopy( pObj, NULL );
51 }
Definition: if.h:303
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
static void If_ObjSetCopy(If_Obj_t *pObj, void *pCopy)
Definition: if.h:387
static If_Obj_t* If_ManCo ( If_Man_t p,
int  i 
)
inlinestatic

Definition at line 367 of file if.h.

367 { return (If_Obj_t *)Vec_PtrEntry( p->vCos, i ); }
Definition: if.h:303
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t * vCos
Definition: if.h:188
Vec_Ptr_t* If_ManCollectMappingDirect ( If_Man_t p)

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

Synopsis [Collects nodes used in the mapping in the topological order.]

Description []

SideEffects []

SeeAlso []

Definition at line 462 of file ifUtil.c.

463 {
464  Vec_Ptr_t * vOrder;
465  If_Obj_t * pObj;
466  int i;
467  If_ManMarkMapping( p );
468  vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
469  If_ManForEachObj( p, pObj, i )
470  if ( If_ObjIsAnd(pObj) && pObj->nRefs )
471  Vec_PtrPush( vOrder, pObj );
472  return vOrder;
473 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
void If_ManMarkMapping(If_Man_t *p)
Definition: ifUtil.c:434
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
if(last==0)
Definition: sparse_int.h:34
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Int_t* If_ManCollectMappingInt ( If_Man_t p)

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

Synopsis [Collects nodes used in the mapping in the topological order.]

Description [Represents mapping as an array of integers.]

SideEffects []

SeeAlso []

Definition at line 486 of file ifUtil.c.

487 {
488  Vec_Int_t * vOrder;
489  If_Cut_t * pCutBest;
490  If_Obj_t * pObj;
491  int i, k, nLeaves, * ppLeaves;
492  If_ManMarkMapping( p );
493  vOrder = Vec_IntAlloc( If_ManObjNum(p) );
494  If_ManForEachObj( p, pObj, i )
495  if ( If_ObjIsAnd(pObj) && pObj->nRefs )
496  {
497  pCutBest = If_ObjCutBest( pObj );
498  nLeaves = If_CutLeaveNum( pCutBest );
499  ppLeaves = If_CutLeaves( pCutBest );
500  // save the number of leaves, the leaves, and finally, the root
501  Vec_IntPush( vOrder, nLeaves );
502  for ( k = 0; k < nLeaves; k++ )
503  Vec_IntPush( vOrder, ppLeaves[k] );
504  Vec_IntPush( vOrder, pObj->Id );
505  }
506  return vOrder;
507 }
int Id
Definition: if.h:316
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
Definition: if.h:275
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
void If_ManMarkMapping(If_Man_t *p)
Definition: ifUtil.c:434
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int * If_CutLeaves(If_Cut_t *pCut)
Definition: if.h:391
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
void If_ManComputeRequired ( If_Man_t p)

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

Synopsis [Computes the required times of all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 294 of file ifTime.c.

295 {
296  If_Obj_t * pObj;
297  int i, Counter;
298  float reqTime;
299 
300  // compute area, clean required times, collect nodes used in the mapping
301 // p->AreaGlo = If_ManScanMapping( p );
302  If_ManMarkMapping( p );
303  if ( p->pManTim == NULL )
304  {
305  // consider the case when the required times are given
306  if ( p->pPars->pTimesReq && !p->pPars->fAreaOnly )
307  {
308  // make sure that the required time hold
309  Counter = 0;
310  If_ManForEachCo( p, pObj, i )
311  {
312  if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
313  {
315  Counter++;
316  // Abc_Print( 0, "Required times are violated for output %d (arr = %d; req = %d).\n",
317  // i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
318  }
319  else
320  If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
321  }
322  if ( Counter && !p->fReqTimeWarn )
323  {
324  Abc_Print( 0, "Required times are exceeded at %d output%s. The earliest arrival times are used.\n", Counter, Counter > 1 ? "s":"" );
325  p->fReqTimeWarn = 1;
326  }
327  }
328  else
329  {
330  // get the global required times
331  p->RequiredGlo = If_ManDelayMax( p, 0 );
332 
333  // find new delay target
334  if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
335  p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
336 
337  // update the required times according to the target
338  if ( p->pPars->DelayTarget != -1 )
339  {
340  if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
341  {
342  if ( p->fNextRound == 0 )
343  {
344  p->fNextRound = 1;
345  Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
346  }
347  }
348  else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
349  {
350  if ( p->fNextRound == 0 )
351  {
352  p->fNextRound = 1;
353 // Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
354  }
355  p->RequiredGlo = p->pPars->DelayTarget;
356  }
357  }
358  else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
360  // do not propagate required times if area minimization is requested
361  if ( p->pPars->fAreaOnly )
362  return;
363  // set the required times for the POs
364  if ( p->pPars->fDoAverage )
365  {
366  if ( p->pPars->nRelaxRatio )
367  {
368  If_ManForEachCo( p, pObj, i )
369  If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj)) * (100.0 + p->pPars->nRelaxRatio) / 100.0;
370  }
371  else
372  {
373  If_ManForEachCo( p, pObj, i )
374  If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj));
375  }
376  }
377  else if ( p->pPars->fLatchPaths )
378  {
379  If_ManForEachLatchInput( p, pObj, i )
380  If_ObjFanin0(pObj)->Required = p->RequiredGlo;
381  }
382  else
383  {
384  If_ManForEachCo( p, pObj, i )
385  If_ObjFanin0(pObj)->Required = p->RequiredGlo;
386  }
387  }
388  // go through the nodes in the reverse topological order
389  // Vec_PtrForEachEntry( If_Obj_t *, p->vMapped, pObj, i )
390  // If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
391  If_ManForEachObjReverse( p, pObj, i )
392  {
393  if ( pObj->nRefs == 0 )
394  continue;
395  If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
396  }
397  }
398  else
399  {
400  // get the global required times
401  p->RequiredGlo = If_ManDelayMax( p, 0 );
402 
403  // find new delay target
404  if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
405  p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
406 
407  // update the required times according to the target
408  if ( p->pPars->DelayTarget != -1 )
409  {
410  if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
411  {
412  if ( p->fNextRound == 0 )
413  {
414  p->fNextRound = 1;
415  Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
416  }
417  }
418  else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
419  {
420  if ( p->fNextRound == 0 )
421  {
422  p->fNextRound = 1;
423 // Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
424  }
425  p->RequiredGlo = p->pPars->DelayTarget;
426  }
427  }
428  else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
429  p->RequiredGlo = p->pPars->DelayTargetNew;
430 
431  // do not propagate required times if area minimization is requested
432  if ( p->pPars->fAreaOnly )
433  return;
434  // set the required times for the POs
435  Tim_ManIncrementTravId( p->pManTim );
436  if ( p->vCoAttrs )
437  {
438  assert( If_ManCoNum(p) == Vec_IntSize(p->vCoAttrs) );
439  If_ManForEachCo( p, pObj, i )
440  {
441  if ( Vec_IntEntry(p->vCoAttrs, i) == -1 ) // -1=internal
442  continue;
443  if ( Vec_IntEntry(p->vCoAttrs, i) == 0 ) // 0=optimize
444  Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
445  else if ( Vec_IntEntry(p->vCoAttrs, i) == 1 ) // 1=keep
446  Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
447  else if ( Vec_IntEntry(p->vCoAttrs, i) == 2 ) // 2=relax
448  Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
449  else assert( 0 );
450  }
451  }
452  else if ( p->pPars->fDoAverage )
453  {
454  if ( p->pPars->nRelaxRatio )
455  {
456  If_ManForEachCo( p, pObj, i )
457  Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) * (100.0 + p->pPars->nRelaxRatio) / 100.0 );
458  }
459  else
460  {
461  If_ManForEachCo( p, pObj, i )
462  Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
463  }
464  }
465  else if ( p->pPars->fLatchPaths )
466  {
467  If_ManForEachPo( p, pObj, i )
468  Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
469  If_ManForEachLatchInput( p, pObj, i )
470  Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
471  }
472  else
473  {
474  Tim_ManInitPoRequiredAll( p->pManTim, p->RequiredGlo );
475 // If_ManForEachCo( p, pObj, i )
476 // Tim_ManSetCoRequired( p->pManTim, pObj->IdPio, p->RequiredGlo );
477  }
478  // go through the nodes in the reverse topological order
479  If_ManForEachObjReverse( p, pObj, i )
480  {
481  if ( If_ObjIsAnd(pObj) )
482  {
483  if ( pObj->nRefs == 0 )
484  continue;
485  If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
486  }
487  else if ( If_ObjIsCi(pObj) )
488  {
489  reqTime = pObj->Required;
490  Tim_ManSetCiRequired( p->pManTim, pObj->IdPio, reqTime );
491  }
492  else if ( If_ObjIsCo(pObj) )
493  {
494  reqTime = Tim_ManGetCoRequired( p->pManTim, pObj->IdPio );
495  If_ObjFanin0(pObj)->Required = IF_MIN( reqTime, If_ObjFanin0(pObj)->Required );
496  }
497  else if ( If_ObjIsConst1(pObj) )
498  {
499  }
500  else // add the node to the mapper
501  assert( 0 );
502  }
503  }
504 }
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition: timTrav.c:44
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
#define If_ManForEachLatchInput(p, pObj, i)
Definition: if.h:457
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
float Required
Definition: if.h:325
int fDoAverage
Definition: if.h:139
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition: ifTime.c:250
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
#define If_ManForEachPo(p, pObj, i)
Definition: if.h:454
float DelayTargetNew
Definition: if.h:158
Tim_Man_t * pManTim
Definition: if.h:263
void Tim_ManSetCiRequired(Tim_Man_t *p, int iCi, float Delay)
Definition: timTime.c:135
#define If_ManForEachObjReverse(p, pObj, i)
Definition: if.h:465
int fAreaOnly
Definition: if.h:145
float RequiredGlo
Definition: if.h:196
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
int fReqTimeWarn
Definition: if.h:212
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define IF_MIN(a, b)
MACRO DEFINITIONS ///.
Definition: if.h:436
static int Counter
float * pTimesReq
Definition: if.h:162
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
float fEpsilon
Definition: if.h:195
static float If_ObjArrTime(If_Obj_t *pObj)
Definition: if.h:405
#define IF_FLOAT_LARGE
Definition: if.h:440
int nRelaxRatio
Definition: if.h:111
If_Par_t * pPars
Definition: if.h:184
float DelayTarget
Definition: if.h:109
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define If_ManForEachCo(p, pObj, i)
Definition: if.h:448
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
void If_CutPropagateRequired(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut, float ObjRequired)
Definition: ifTime.c:170
float Tim_ManGetCoRequired(Tim_Man_t *p, int iCo)
Definition: timTime.c:222
#define assert(ex)
Definition: util_old.h:213
static int If_ManCoNum(If_Man_t *p)
Definition: if.h:361
void Tim_ManSetCoRequired(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:154
int fNextRound
Definition: if.h:206
void If_ManMarkMapping(If_Man_t *p)
Definition: ifUtil.c:434
void Tim_ManInitPoRequiredAll(Tim_Man_t *p, float Delay)
Definition: timTime.c:97
void If_ManComputeSwitching ( If_Man_t pIfMan)

FUNCTION DEFINITIONS ///.

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

Synopsis [Interface with the FPGA mapping package.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file abcIf.c.

59 {
60  abctime clk = Abc_Clock();
61  Gia_Man_t * pNew;
62  Vec_Int_t * vCopy;
63  If_Obj_t * pIfObj;
64  int i;
65  assert( pIfMan->vSwitching == NULL );
66  // create the new manager
67  pNew = Gia_ManStart( If_ManObjNum(pIfMan) );
68  vCopy = Vec_IntAlloc( If_ManObjNum(pIfMan) );
69  // constant and inputs
70  Vec_IntPush( vCopy, 1 );
71  If_ManForEachCi( pIfMan, pIfObj, i )
72  Vec_IntPush( vCopy, Gia_ManAppendCi(pNew) );
73  // internal nodes
74  If_ManForEachNode( pIfMan, pIfObj, i )
75  {
76  int iLit0 = Abc_LitNotCond( Vec_IntEntry(vCopy, If_ObjFanin0(pIfObj)->Id), If_ObjFaninC0(pIfObj) );
77  int iLit1 = Abc_LitNotCond( Vec_IntEntry(vCopy, If_ObjFanin1(pIfObj)->Id), If_ObjFaninC1(pIfObj) );
78  Vec_IntPush( vCopy, Gia_ManAppendAnd(pNew, iLit0, iLit1) );
79  }
80  // outputs
81  If_ManForEachCo( pIfMan, pIfObj, i )
82  {
83  int iLit0 = Abc_LitNotCond( Vec_IntEntry(vCopy, If_ObjFanin0(pIfObj)->Id), If_ObjFaninC0(pIfObj) );
84  Vec_IntPush( vCopy, Gia_ManAppendCo(pNew, iLit0) );
85  }
86  assert( Vec_IntSize(vCopy) == If_ManObjNum(pIfMan) );
87  Vec_IntFree( vCopy );
88  // compute switching activity
89  pIfMan->vSwitching = Gia_ManComputeSwitchProbs( pNew, 48, 16, 0 );
90  Gia_ManStop( pNew );
91  if ( pIfMan->pPars->fVerbose )
92  Abc_PrintTime( 1, "Computing switching activity", Abc_Clock() - clk );
93 }
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
#define If_ManForEachNode(p, pObj, i)
Definition: if.h:468
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: if.h:303
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int If_ObjFaninC0(If_Obj_t *pObj)
Definition: if.h:382
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static abctime Abc_Clock()
Definition: abc_global.h:279
Vec_Int_t * vSwitching
Definition: if.h:208
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static int If_ObjFaninC1(If_Obj_t *pObj)
Definition: if.h:383
#define If_ManForEachCi(p, pObj, i)
Definition: if.h:445
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define If_ManForEachCo(p, pObj, i)
Definition: if.h:448
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_INT64_T abctime
Definition: abc_global.h:278
Vec_Int_t * Gia_ManComputeSwitchProbs(Gia_Man_t *pGia, int nFrames, int nPref, int fProbOne)
Definition: giaSwitch.c:658
static If_Obj_t* If_ManConst1 ( If_Man_t p)
inlinestatic

Definition at line 365 of file if.h.

365 { return p->pConst1; }
If_Obj_t * pConst1
Definition: if.h:186
static int If_ManCoNum ( If_Man_t p)
inlinestatic

Definition at line 361 of file if.h.

361 { return p->nObjs[IF_CO]; }
Definition: if.h:67
int nObjs[IF_VOID]
Definition: if.h:192
int If_ManCountSpecialPos ( If_Man_t p)

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

Synopsis [Returns the number of POs pointing to the same internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 520 of file ifUtil.c.

521 {
522  If_Obj_t * pObj;
523  int i, Counter = 0;
524  // clean all marks
525  If_ManForEachPo( p, pObj, i )
526  If_ObjFanin0(pObj)->fMark = 0;
527  // label nodes
528  If_ManForEachPo( p, pObj, i )
529  if ( !If_ObjFaninC0(pObj) )
530  If_ObjFanin0(pObj)->fMark = 1;
531  // label nodes
532  If_ManForEachPo( p, pObj, i )
533  if ( If_ObjFaninC0(pObj) )
534  Counter += If_ObjFanin0(pObj)->fMark;
535  // clean all marks
536  If_ManForEachPo( p, pObj, i )
537  If_ObjFanin0(pObj)->fMark = 0;
538  return Counter;
539 }
Definition: if.h:303
static int If_ObjFaninC0(If_Obj_t *pObj)
Definition: if.h:382
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
#define If_ManForEachPo(p, pObj, i)
Definition: if.h:454
if(last==0)
Definition: sparse_int.h:34
static int Counter
If_Obj_t* If_ManCreateAnd ( If_Man_t p,
If_Obj_t pFan0,
If_Obj_t pFan1 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 366 of file ifMan.c.

367 {
368  If_Obj_t * pObj;
369  // perform constant propagation
370  if ( pFan0 == pFan1 )
371  return pFan0;
372  if ( pFan0 == If_Not(pFan1) )
373  return If_Not(p->pConst1);
374  if ( If_Regular(pFan0) == p->pConst1 )
375  return pFan0 == p->pConst1 ? pFan1 : If_Not(p->pConst1);
376  if ( If_Regular(pFan1) == p->pConst1 )
377  return pFan1 == p->pConst1 ? pFan0 : If_Not(p->pConst1);
378  // get memory for the new object
379  pObj = If_ManSetupObj( p );
380  pObj->Type = IF_AND;
381  pObj->fCompl0 = If_IsComplement(pFan0); pFan0 = If_Regular(pFan0);
382  pObj->fCompl1 = If_IsComplement(pFan1); pFan1 = If_Regular(pFan1);
383  pObj->pFanin0 = pFan0; pFan0->nRefs++; pFan0->nVisits++; pFan0->nVisitsCopy++;
384  pObj->pFanin1 = pFan1; pFan1->nRefs++; pFan1->nVisits++; pFan1->nVisitsCopy++;
385  pObj->fPhase = (pObj->fCompl0 ^ pFan0->fPhase) & (pObj->fCompl1 ^ pFan1->fPhase);
386  pObj->Level = 1 + IF_MAX( pFan0->Level, pFan1->Level );
387  if ( p->nLevelMax < (int)pObj->Level )
388  p->nLevelMax = (int)pObj->Level;
389  p->nObjs[IF_AND]++;
390  return pObj;
391 }
If_Obj_t * pFanin0
Definition: if.h:321
#define IF_MAX(a, b)
Definition: if.h:437
unsigned Type
Definition: if.h:305
Definition: if.h:303
int nLevelMax
Definition: if.h:194
int nRefs
Definition: if.h:318
Definition: if.h:68
static If_Obj_t * If_Not(If_Obj_t *p)
Definition: if.h:356
static ABC_NAMESPACE_IMPL_START If_Obj_t * If_ManSetupObj(If_Man_t *p)
DECLARATIONS ///.
Definition: ifMan.c:522
If_Obj_t * pFanin1
Definition: if.h:322
unsigned Level
Definition: if.h:315
int nVisitsCopy
Definition: if.h:320
static If_Obj_t * If_Regular(If_Obj_t *p)
Definition: if.h:355
int nVisits
Definition: if.h:319
int nObjs[IF_VOID]
Definition: if.h:192
static int If_IsComplement(If_Obj_t *p)
Definition: if.h:358
unsigned fCompl1
Definition: if.h:307
unsigned fCompl0
Definition: if.h:306
unsigned fPhase
Definition: if.h:308
If_Obj_t * pConst1
Definition: if.h:186
void If_ManCreateChoice ( If_Man_t p,
If_Obj_t pObj 
)

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

Synopsis [Creates the choice node.]

Description [Should be called after the equivalence class nodes are linked.]

SideEffects []

SeeAlso []

Definition at line 442 of file ifMan.c.

443 {
444  If_Obj_t * pTemp;
445  // mark the node as a representative if its class
446  assert( pObj->fRepr == 0 );
447  pObj->fRepr = 1;
448  // update the level of this node (needed for correct required time computation)
449  for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
450  {
451  pObj->Level = IF_MAX( pObj->Level, pTemp->Level );
452  pTemp->nVisits++; pTemp->nVisitsCopy++;
453  }
454  // mark the largest level
455  if ( p->nLevelMax < (int)pObj->Level )
456  p->nLevelMax = (int)pObj->Level;
457  p->nChoices++;
458 }
#define IF_MAX(a, b)
Definition: if.h:437
Definition: if.h:303
unsigned fRepr
Definition: if.h:309
int nLevelMax
Definition: if.h:194
int nChoices
Definition: if.h:207
If_Obj_t * pEquiv
Definition: if.h:323
unsigned Level
Definition: if.h:315
int nVisitsCopy
Definition: if.h:320
int nVisits
Definition: if.h:319
#define assert(ex)
Definition: util_old.h:213
If_Obj_t* If_ManCreateCi ( If_Man_t p)

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

Synopsis [Creates primary input.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file ifMan.c.

317 {
318  If_Obj_t * pObj;
319  pObj = If_ManSetupObj( p );
320  pObj->Type = IF_CI;
321  pObj->IdPio = Vec_PtrSize( p->vCis );
322  Vec_PtrPush( p->vCis, pObj );
323  p->nObjs[IF_CI]++;
324  return pObj;
325 }
unsigned Type
Definition: if.h:305
Definition: if.h:303
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t * vCis
Definition: if.h:187
static ABC_NAMESPACE_IMPL_START If_Obj_t * If_ManSetupObj(If_Man_t *p)
DECLARATIONS ///.
Definition: ifMan.c:522
Definition: if.h:66
int nObjs[IF_VOID]
Definition: if.h:192
int IdPio
Definition: if.h:317
If_Obj_t* If_ManCreateCo ( If_Man_t p,
If_Obj_t pDriver 
)

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

Synopsis [Creates primary output with the given driver.]

Description []

SideEffects []

SeeAlso []

Definition at line 338 of file ifMan.c.

339 {
340  If_Obj_t * pObj;
341  pObj = If_ManSetupObj( p );
342  pObj->IdPio = Vec_PtrSize( p->vCos );
343  Vec_PtrPush( p->vCos, pObj );
344  pObj->Type = IF_CO;
345  pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver);
346  pObj->pFanin0 = pDriver; pDriver->nRefs++;
347  pObj->fPhase = (pObj->fCompl0 ^ pDriver->fPhase);
348  pObj->Level = pDriver->Level;
349  if ( p->nLevelMax < (int)pObj->Level )
350  p->nLevelMax = (int)pObj->Level;
351  p->nObjs[IF_CO]++;
352  return pObj;
353 }
If_Obj_t * pFanin0
Definition: if.h:321
unsigned Type
Definition: if.h:305
Definition: if.h:303
int nLevelMax
Definition: if.h:194
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int nRefs
Definition: if.h:318
Definition: if.h:67
static ABC_NAMESPACE_IMPL_START If_Obj_t * If_ManSetupObj(If_Man_t *p)
DECLARATIONS ///.
Definition: ifMan.c:522
unsigned Level
Definition: if.h:315
static If_Obj_t * If_Regular(If_Obj_t *p)
Definition: if.h:355
int nObjs[IF_VOID]
Definition: if.h:192
Vec_Ptr_t * vCos
Definition: if.h:188
static int If_IsComplement(If_Obj_t *p)
Definition: if.h:358
unsigned fCompl0
Definition: if.h:306
unsigned fPhase
Definition: if.h:308
int IdPio
Definition: if.h:317
If_Obj_t* If_ManCreateMux ( If_Man_t p,
If_Obj_t pFan0,
If_Obj_t pFan1,
If_Obj_t pCtrl 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 423 of file ifMan.c.

424 {
425  If_Obj_t * pRes1, * pRes2;
426  pRes1 = If_ManCreateAnd( p, pFan0, If_Not(pCtrl) );
427  pRes2 = If_ManCreateAnd( p, pFan1, pCtrl );
428  return If_Not( If_ManCreateAnd( p, If_Not(pRes1), If_Not(pRes2) ) );
429 }
Definition: if.h:303
static If_Obj_t * If_Not(If_Obj_t *p)
Definition: if.h:356
If_Obj_t * If_ManCreateAnd(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
Definition: ifMan.c:366
If_Obj_t* If_ManCreateXor ( If_Man_t p,
If_Obj_t pFan0,
If_Obj_t pFan1 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 404 of file ifMan.c.

405 {
406  If_Obj_t * pRes1, * pRes2;
407  pRes1 = If_ManCreateAnd( p, If_Not(pFan0), pFan1 );
408  pRes2 = If_ManCreateAnd( p, pFan0, If_Not(pFan1) );
409  return If_Not( If_ManCreateAnd( p, If_Not(pRes1), If_Not(pRes2) ) );
410 }
Definition: if.h:303
static If_Obj_t * If_Not(If_Obj_t *p)
Definition: if.h:356
If_Obj_t * If_ManCreateAnd(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1)
Definition: ifMan.c:366
int If_ManCrossCut ( If_Man_t p)

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

Synopsis [Computes cross-cut of the circuit.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file ifUtil.c.

317 {
318  If_Obj_t * pObj, * pFanin;
319  int i, nCutSize = 0, nCutSizeMax = 0;
320  If_ManForEachObj( p, pObj, i )
321  {
322  if ( !If_ObjIsAnd(pObj) )
323  continue;
324  // consider the node
325  if ( nCutSizeMax < ++nCutSize )
326  nCutSizeMax = nCutSize;
327  if ( pObj->nVisits == 0 )
328  nCutSize--;
329  // consider the fanins
330  pFanin = If_ObjFanin0(pObj);
331  if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
332  nCutSize--;
333  pFanin = If_ObjFanin1(pObj);
334  if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
335  nCutSize--;
336  // consider the choice class
337  if ( pObj->fRepr )
338  for ( pFanin = pObj; pFanin; pFanin = pFanin->pEquiv )
339  if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
340  nCutSize--;
341  }
342  If_ManForEachObj( p, pObj, i )
343  {
344  assert( If_ObjIsCi(pObj) || pObj->fVisit == 0 );
345  pObj->nVisits = pObj->nVisitsCopy;
346  }
347  assert( nCutSize == 0 );
348 // Abc_Print( 1, "Max cross cut size = %6d.\n", nCutSizeMax );
349  return nCutSizeMax;
350 }
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
unsigned fRepr
Definition: if.h:309
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
unsigned fVisit
Definition: if.h:311
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
If_Obj_t * pEquiv
Definition: if.h:323
int nVisitsCopy
Definition: if.h:320
int nVisits
Definition: if.h:319
#define assert(ex)
Definition: util_old.h:213
float If_ManDelayMax ( If_Man_t p,
int  fSeq 
)

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

Synopsis [Returns the max delay of the POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file ifTime.c.

251 {
252  If_Obj_t * pObj;
253  float DelayBest;
254  int i;
255  if ( p->pPars->fLatchPaths && (p->pPars->nLatchesCi == 0 || p->pPars->nLatchesCo == 0) )
256  {
257  Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" );
258  p->pPars->fLatchPaths = 0;
259  }
260  DelayBest = -IF_FLOAT_LARGE;
261  if ( fSeq )
262  {
263  assert( p->pPars->nLatchesCi > 0 );
264  If_ManForEachPo( p, pObj, i )
265  if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
266  DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
267  }
268  else if ( p->pPars->fLatchPaths )
269  {
270  If_ManForEachLatchInput( p, pObj, i )
271  if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
272  DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
273  }
274  else
275  {
276  If_ManForEachCo( p, pObj, i )
277  if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
278  DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
279  }
280  return DelayBest;
281 }
Definition: if.h:303
#define If_ManForEachLatchInput(p, pObj, i)
Definition: if.h:457
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
#define If_ManForEachPo(p, pObj, i)
Definition: if.h:454
int nLatchesCi
Definition: if.h:152
int fLatchPaths
Definition: if.h:117
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static float If_ObjArrTime(If_Obj_t *pObj)
Definition: if.h:405
#define IF_FLOAT_LARGE
Definition: if.h:440
If_Par_t * pPars
Definition: if.h:184
int nLatchesCo
Definition: if.h:153
#define If_ManForEachCo(p, pObj, i)
Definition: if.h:448
#define assert(ex)
Definition: util_old.h:213
void If_ManDerefChoiceCutSet ( If_Man_t p,
If_Obj_t pObj 
)

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

Synopsis [Dereferences cutset of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 645 of file ifMan.c.

646 {
647  If_Obj_t * pTemp;
648  assert( If_ObjIsAnd(pObj) );
649  assert( pObj->fRepr );
650  assert( pObj->nVisits > 0 );
651  // consider the nodes in the choice class
652  for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
653  {
654 // assert( pTemp == pObj || pTemp->nVisits == 1 );
655  if ( --pTemp->nVisits == 0 )
656  {
657 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pTemp->pCutSet );
658  If_ManCutSetRecycle( p, pTemp->pCutSet );
659  pTemp->pCutSet = NULL;
660  }
661  }
662 }
If_Set_t * pCutSet
Definition: if.h:332
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
unsigned fRepr
Definition: if.h:309
static void If_ManCutSetRecycle(If_Man_t *p, If_Set_t *pSet)
Definition: ifMan.c:32
If_Obj_t * pEquiv
Definition: if.h:323
int nVisits
Definition: if.h:319
#define assert(ex)
Definition: util_old.h:213
void If_ManDerefNodeCutSet ( If_Man_t p,
If_Obj_t pObj 
)

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

Synopsis [Dereferences cutset of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 602 of file ifMan.c.

603 {
604  If_Obj_t * pFanin;
605  assert( If_ObjIsAnd(pObj) );
606  // consider the node
607  assert( pObj->nVisits >= 0 );
608  if ( pObj->nVisits == 0 )
609  {
610 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pObj->pCutSet );
611  If_ManCutSetRecycle( p, pObj->pCutSet );
612  pObj->pCutSet = NULL;
613  }
614  // consider the first fanin
615  pFanin = If_ObjFanin0(pObj);
616  assert( pFanin->nVisits > 0 );
617  if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
618  {
619 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pFanin->pCutSet );
620  If_ManCutSetRecycle( p, pFanin->pCutSet );
621  pFanin->pCutSet = NULL;
622  }
623  // consider the second fanin
624  pFanin = If_ObjFanin1(pObj);
625  assert( pFanin->nVisits > 0 );
626  if ( !If_ObjIsCi(pFanin) && --pFanin->nVisits == 0 )
627  {
628 // Mem_FixedEntryRecycle( p->pMemSet, (char *)pFanin->pCutSet );
629  If_ManCutSetRecycle( p, pFanin->pCutSet );
630  pFanin->pCutSet = NULL;
631  }
632 }
If_Set_t * pCutSet
Definition: if.h:332
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static void If_ManCutSetRecycle(If_Man_t *p, If_Set_t *pSet)
Definition: ifMan.c:32
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
int nVisits
Definition: if.h:319
#define assert(ex)
Definition: util_old.h:213
void If_ManImproveMapping ( If_Man_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Improves current mapping using expand/Expand of one cut.]

Description [Assumes current mapping assigned and required times computed.]

SideEffects []

SeeAlso []

Definition at line 51 of file ifReduce.c.

52 {
53  abctime clk;
54 
55  clk = Abc_Clock();
58  if ( p->pPars->fVerbose )
59  {
60  Abc_Print( 1, "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. ",
61  p->RequiredGlo, p->AreaGlo, p->nNets );
62  if ( p->dPower )
63  Abc_Print( 1, "Switch = %7.2f. ", p->dPower );
64  Abc_Print( 1, "Cut = %8d. ", p->nCutsMerged );
65  Abc_PrintTime( 1, "T", Abc_Clock() - clk );
66  }
67 }
float dPower
Definition: if.h:200
int nLutSize
Definition: if.h:103
int fVerbose
Definition: if.h:140
void If_ManComputeRequired(If_Man_t *p)
Definition: ifTime.c:294
int nCutsMerged
Definition: if.h:202
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
float AreaGlo
Definition: if.h:198
float RequiredGlo
Definition: if.h:196
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
If_Par_t * pPars
Definition: if.h:184
static ABC_NAMESPACE_IMPL_START void If_ManImproveExpand(If_Man_t *p, int nLimit)
DECLARATIONS ///.
Definition: ifReduce.c:80
int nNets
Definition: if.h:199
ABC_INT64_T abctime
Definition: abc_global.h:278
static If_Obj_t* If_ManLi ( If_Man_t p,
int  i 
)
inlinestatic

Definition at line 368 of file if.h.

368 { return (If_Obj_t *)Vec_PtrEntry( p->vCos, If_ManCoNum(p) - p->pPars->nLatchesCo + i ); }
Definition: if.h:303
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
If_Par_t * pPars
Definition: if.h:184
int nLatchesCo
Definition: if.h:153
Vec_Ptr_t * vCos
Definition: if.h:188
static int If_ManCoNum(If_Man_t *p)
Definition: if.h:361
static If_Obj_t* If_ManLo ( If_Man_t p,
int  i 
)
inlinestatic

Definition at line 369 of file if.h.

369 { return (If_Obj_t *)Vec_PtrEntry( p->vCis, If_ManCiNum(p) - p->pPars->nLatchesCi + i ); }
Definition: if.h:303
int nLatchesCi
Definition: if.h:152
static int If_ManCiNum(If_Man_t *p)
Definition: if.h:360
Vec_Ptr_t * vCis
Definition: if.h:187
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
If_Par_t * pPars
Definition: if.h:184
void If_ManMarkMapping ( If_Man_t p)

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

Synopsis [Computes area, references, and nodes used in the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 434 of file ifUtil.c.

435 {
436  If_Obj_t * pObj;
437  int i;
438  If_ManForEachObj( p, pObj, i )
439  {
440  pObj->Required = IF_FLOAT_LARGE;
441  pObj->nVisits = pObj->nVisitsCopy;
442  pObj->nRefs = 0;
443  }
444  p->nNets = 0;
445  p->dPower = 0.0;
446  p->AreaGlo = 0.0;
447  If_ManForEachCo( p, pObj, i )
448  p->AreaGlo += If_ManMarkMapping_rec( p, If_ObjFanin0(pObj) );
449 }
float dPower
Definition: if.h:200
Definition: if.h:303
float Required
Definition: if.h:325
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
int nRefs
Definition: if.h:318
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
float AreaGlo
Definition: if.h:198
int nVisitsCopy
Definition: if.h:320
#define IF_FLOAT_LARGE
Definition: if.h:440
#define If_ManForEachCo(p, pObj, i)
Definition: if.h:448
float If_ManMarkMapping_rec(If_Man_t *p, If_Obj_t *pObj)
Definition: ifUtil.c:400
int nVisits
Definition: if.h:319
int nNets
Definition: if.h:199
static If_Obj_t* If_ManObj ( If_Man_t p,
int  i 
)
inlinestatic

Definition at line 370 of file if.h.

370 { return (If_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }
Vec_Ptr_t * vObjs
Definition: if.h:189
Definition: if.h:303
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int If_ManObjNum ( If_Man_t p)
inlinestatic

Definition at line 363 of file if.h.

363 { return Vec_PtrSize(p->vObjs); }
Vec_Ptr_t * vObjs
Definition: if.h:189
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int If_ManPerformMapping ( If_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file ifCore.c.

81 {
82  p->pPars->fAreaOnly = p->pPars->fArea; // temporary
83  // create the CI cutsets
85  // allocate memory for other cutsets
87  // derive reverse top order
88  p->vObjsRev = If_ManReverseOrder( p );
89  return If_ManPerformMappingComb( p );
90 }
int If_ManPerformMappingComb(If_Man_t *p)
Definition: ifCore.c:104
Vec_Ptr_t * vObjsRev
Definition: if.h:190
void If_ManSetupSetAll(If_Man_t *p, int nCrossCut)
Definition: ifMan.c:675
int fAreaOnly
Definition: if.h:145
Vec_Ptr_t * If_ManReverseOrder(If_Man_t *p)
Definition: ifUtil.c:363
int If_ManCrossCut(If_Man_t *p)
Definition: ifUtil.c:316
void If_ManSetupCiCutSets(If_Man_t *p)
Definition: ifMan.c:548
If_Par_t * pPars
Definition: if.h:184
int fArea
Definition: if.h:114
int If_ManPerformMappingComb ( If_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file ifCore.c.

105 {
106  If_Obj_t * pObj;
107  abctime clkTotal = Abc_Clock();
108  int i;
109 
110  // set arrival times and fanout estimates
111  If_ManForEachCi( p, pObj, i )
112  {
113  If_ObjSetArrTime( pObj, p->pPars->pTimesArr ? p->pPars->pTimesArr[i] : (float)0.0 );
114  pObj->EstRefs = (float)1.0;
115  }
116 
117  // delay oriented mapping
118  if ( p->pPars->fPreprocess && !p->pPars->fArea )
119  {
120  // map for delay
121  If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 1, 1, "Delay" );
122  // map for delay second option
123  p->pPars->fFancy = 1;
125  If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 1, 0, "Delay-2" );
126  p->pPars->fFancy = 0;
127  // map for area
128  p->pPars->fArea = 1;
130  If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 1, 0, "Area" );
131  p->pPars->fArea = 0;
132  }
133  else
134  If_ManPerformMappingRound( p, p->pPars->nCutsMax, 0, 0, 1, "Delay" );
135 
136  // try to improve area by expanding and reducing the cuts
137  if ( p->pPars->fExpRed )
139 
140  // area flow oriented mapping
141  for ( i = 0; i < p->pPars->nFlowIters; i++ )
142  {
143  If_ManPerformMappingRound( p, p->pPars->nCutsMax, 1, 0, 0, "Flow" );
144  if ( p->pPars->fExpRed )
146  }
147 
148  // area oriented mapping
149  for ( i = 0; i < p->pPars->nAreaIters; i++ )
150  {
151  If_ManPerformMappingRound( p, p->pPars->nCutsMax, 2, 0, 0, "Area" );
152  if ( p->pPars->fExpRed )
154  }
155 
156  if ( p->pPars->fVerbose )
157  {
158 // Abc_Print( 1, "Total memory = %7.2f MB. Peak cut memory = %7.2f MB. ",
159 // 1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
160 // 1.0 * p->nSetBytes * Mem_FixedReadMaxEntriesUsed(p->pMemSet) / (1<<20) );
161  Abc_PrintTime( 1, "Total time", Abc_Clock() - clkTotal );
162  }
163 // Abc_Print( 1, "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) );
164  s_MappingTime = Abc_Clock() - clkTotal;
165 // Abc_Print( 1, "Special POs = %d.\n", If_ManCountSpecialPos(p) );
166 
167 /*
168  {
169  static char * pLastName = NULL;
170  FILE * pTable = fopen( "fpga/ucsb/stats.txt", "a+" );
171  if ( pLastName == NULL || strcmp(pLastName, p->pName) )
172  {
173  fprintf( pTable, "\n" );
174  fprintf( pTable, "%s ", p->pName );
175 
176  fprintf( pTable, "%d ", If_ManCiNum(p) );
177  fprintf( pTable, "%d ", If_ManCoNum(p) );
178  fprintf( pTable, "%d ", If_ManAndNum(p) );
179 
180  ABC_FREE( pLastName );
181  pLastName = Abc_UtilStrsav( p->pName );
182  }
183 
184  fprintf( pTable, "%d ", (int)p->AreaGlo );
185  fprintf( pTable, "%d ", (int)p->RequiredGlo );
186  fclose( pTable );
187  }
188 */
189  p->pPars->FinalDelay = p->RequiredGlo;
190  return 1;
191 }
void If_ManResetOriginalRefs(If_Man_t *p)
Definition: ifUtil.c:287
Definition: if.h:303
int fVerbose
Definition: if.h:140
ABC_NAMESPACE_IMPL_START abctime s_MappingTime
DECLARATIONS ///.
Definition: abcPrint.c:44
int If_ManPerformMappingRound(If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
Definition: ifMap.c:491
static abctime Abc_Clock()
Definition: abc_global.h:279
int fExpRed
Definition: if.h:116
int nFlowIters
Definition: if.h:105
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
#define If_ManForEachCi(p, pObj, i)
Definition: if.h:445
int fPreprocess
Definition: if.h:113
float RequiredGlo
Definition: if.h:196
float * pTimesArr
Definition: if.h:161
static void If_ObjSetArrTime(If_Obj_t *pObj, float ArrTime)
Definition: if.h:406
int fFancy
Definition: if.h:115
float FinalDelay
Definition: if.h:159
If_Par_t * pPars
Definition: if.h:184
int nAreaIters
Definition: if.h:106
float EstRefs
Definition: if.h:324
int nCutsMax
Definition: if.h:104
int fArea
Definition: if.h:114
void If_ManImproveMapping(If_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: ifReduce.c:51
ABC_INT64_T abctime
Definition: abc_global.h:278
int If_ManPerformMappingRound ( If_Man_t p,
int  nCutsUsed,
int  Mode,
int  fPreprocess,
int  fFirst,
char *  pLabel 
)

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

Synopsis [Performs one mapping pass over all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 491 of file ifMap.c.

492 {
493 // ProgressBar * pProgress;
494  If_Obj_t * pObj;
495  int i;
496  abctime clk = Abc_Clock();
497  float arrTime;
498  assert( Mode >= 0 && Mode <= 2 );
499  p->nBestCutSmall[0] = p->nBestCutSmall[1] = 0;
500  // set the sorting function
501  if ( Mode || p->pPars->fArea ) // area
502  p->SortMode = 1;
503  else if ( p->pPars->fFancy )
504  p->SortMode = 2;
505  else
506  p->SortMode = 0;
507  // set the cut number
508  p->nCutsUsed = nCutsUsed;
509  p->nCutsMerged = 0;
510  // make sure the visit counters are all zero
511  If_ManForEachNode( p, pObj, i )
512  assert( pObj->nVisits == pObj->nVisitsCopy );
513  // map the internal nodes
514  if ( p->pManTim != NULL )
515  {
517  If_ManForEachObj( p, pObj, i )
518  {
519  if ( If_ObjIsAnd(pObj) )
520  {
521  If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
522  if ( pObj->fRepr )
523  If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
524  }
525  else if ( If_ObjIsCi(pObj) )
526  {
527 //Abc_Print( 1, "processing CI %d\n", pObj->Id );
528  arrTime = Tim_ManGetCiArrival( p->pManTim, pObj->IdPio );
529  If_ObjSetArrTime( pObj, arrTime );
530  }
531  else if ( If_ObjIsCo(pObj) )
532  {
533  arrTime = If_ObjArrTime( If_ObjFanin0(pObj) );
534  Tim_ManSetCoArrival( p->pManTim, pObj->IdPio, arrTime );
535  }
536  else if ( If_ObjIsConst1(pObj) )
537  {
538  }
539  else
540  assert( 0 );
541  }
542 // Tim_ManPrint( p->pManTim );
543  }
544  else
545  {
546  // pProgress = Extra_ProgressBarStart( stdout, If_ManObjNum(p) );
547  If_ManForEachNode( p, pObj, i )
548  {
549  // Extra_ProgressBarUpdate( pProgress, i, pLabel );
550  If_ObjPerformMappingAnd( p, pObj, Mode, fPreprocess, fFirst );
551  if ( pObj->fRepr )
552  If_ObjPerformMappingChoice( p, pObj, Mode, fPreprocess );
553  }
554  }
555 // Extra_ProgressBarStop( pProgress );
556  // make sure the visit counters are all zero
557  If_ManForEachNode( p, pObj, i )
558  assert( pObj->nVisits == 0 );
559  // compute required times and stats
561 // Tim_ManPrint( p->pManTim );
562  if ( p->pPars->fVerbose )
563  {
564  char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
565  Abc_Print( 1, "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. ",
566  Symb, p->RequiredGlo, p->AreaGlo, p->nNets );
567  if ( p->dPower )
568  Abc_Print( 1, "Switch = %7.2f. ", p->dPower );
569  Abc_Print( 1, "Cut = %8d. ", p->nCutsMerged );
570  Abc_PrintTime( 1, "T", Abc_Clock() - clk );
571 // Abc_Print( 1, "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
572 // p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
573  }
574  return 1;
575 }
int nBestCutSmall[2]
Definition: if.h:258
int nCutsUsed
Definition: if.h:201
#define If_ManForEachNode(p, pObj, i)
Definition: if.h:468
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition: timTrav.c:44
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
unsigned fRepr
Definition: if.h:309
void If_ManComputeRequired(If_Man_t *p)
Definition: ifTime.c:294
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:116
int nCutsMerged
Definition: if.h:202
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static abctime Abc_Clock()
Definition: abc_global.h:279
void If_ObjPerformMappingAnd(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess, int fFirst)
Definition: ifMap.c:95
Tim_Man_t * pManTim
Definition: if.h:263
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
if(last==0)
Definition: sparse_int.h:34
static void If_ObjSetArrTime(If_Obj_t *pObj, float ArrTime)
Definition: if.h:406
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static float If_ObjArrTime(If_Obj_t *pObj)
Definition: if.h:405
int fFancy
Definition: if.h:115
If_Par_t * pPars
Definition: if.h:184
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
#define assert(ex)
Definition: util_old.h:213
int SortMode
Definition: if.h:205
int fArea
Definition: if.h:114
ABC_INT64_T abctime
Definition: abc_global.h:278
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition: timTime.c:174
int IdPio
Definition: if.h:317
void If_ObjPerformMappingChoice(If_Man_t *p, If_Obj_t *pObj, int Mode, int fPreprocess)
Definition: ifMap.c:407
int If_ManPerformMappingSeq ( If_Man_t p)

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

Synopsis [Performs sequential mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 334 of file ifSeq.c.

335 {
336  abctime clkTotal = Abc_Clock();
337  int PeriodBest;
338 
339  p->SortMode = 0;
340 
341  // perform combinational mapping to get the upper bound on the clock period
342  If_ManPerformMappingRound( p, 1, 0, 0, 1, NULL );
343  p->RequiredGlo = If_ManDelayMax( p, 0 );
344  p->RequiredGlo2 = p->RequiredGlo;
345 
346  // set direct linking of latches with their inputs
348 
349  // collect latches
351 
352  // set parameters
353  p->nCutsUsed = p->pPars->nCutsMax;
354  p->nAttempts = 0;
355  p->nMaxIters = 50;
356  p->Period = (int)p->RequiredGlo;
357 
358  // make sure the clock period works
359  if ( !If_ManBinarySearchPeriod( p ) )
360  {
361  Abc_Print( 1, "If_ManPerformMappingSeq(): The upper bound on the clock period cannot be computed.\n" );
362  return 0;
363  }
364 
365  // perform binary search
366  PeriodBest = If_ManBinarySearch_rec( p, 0, p->Period );
367 
368  // recompute the best l-values
369  if ( p->Period != PeriodBest )
370  {
371  p->Period = PeriodBest;
372  if ( !If_ManBinarySearchPeriod( p ) )
373  {
374  Abc_Print( 1, "If_ManPerformMappingSeq(): The final clock period cannot be confirmed.\n" );
375  return 0;
376  }
377  }
378 // if ( p->pPars->fVerbose )
379  {
380  Abc_Print( 1, "The best clock period is %3d. ", p->Period );
381  Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
382  }
383  p->RequiredGlo = (float)(PeriodBest);
384 
385  // postprocess it using combinational mapping
387  s_MappingTime = Abc_Clock() - clkTotal;
388  return 1;
389 }
float RequiredGlo2
Definition: if.h:197
int nCutsUsed
Definition: if.h:201
int nMaxIters
Definition: if.h:223
int If_ManBinarySearch_rec(If_Man_t *p, int FiMin, int FiMax)
Definition: ifSeq.c:269
int If_ManPerformMappingRound(If_Man_t *p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char *pLabel)
Definition: ifMap.c:491
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int If_ManBinarySearchPeriod(If_Man_t *p)
Definition: ifSeq.c:198
float RequiredGlo
Definition: if.h:196
if(last==0)
Definition: sparse_int.h:34
Vec_Ptr_t * If_ManCollectLatches(If_Man_t *p)
Definition: ifSeq.c:95
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nAttempts
Definition: if.h:222
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition: ifTime.c:250
void If_ManPrepareMappingSeq(If_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: ifSeq.c:47
ABC_NAMESPACE_IMPL_START abctime s_MappingTime
DECLARATIONS ///.
Definition: abcPrint.c:44
If_Par_t * pPars
Definition: if.h:184
int Period
Definition: if.h:224
void If_ManPerformMappingSeqPost(If_Man_t *p)
Definition: ifSeq.c:293
int nCutsMax
Definition: if.h:104
int SortMode
Definition: if.h:205
Vec_Ptr_t * vLatchOrder
Definition: if.h:220
ABC_INT64_T abctime
Definition: abc_global.h:278
void If_ManResetOriginalRefs ( If_Man_t p)

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

Synopsis [Computes area, references, and nodes used in the mapping.]

Description [Collects the nodes in reverse topological order in array p->vMapping.]

SideEffects []

SeeAlso []

Definition at line 287 of file ifUtil.c.

288 {
289  If_Obj_t * pObj;
290  int i;
291  If_ManForEachObj( p, pObj, i )
292  pObj->nRefs = 0;
293  If_ManForEachObj( p, pObj, i )
294  {
295  if ( If_ObjIsAnd(pObj) )
296  {
297  pObj->pFanin0->nRefs++;
298  pObj->pFanin1->nRefs++;
299  }
300  else if ( If_ObjIsCo(pObj) )
301  pObj->pFanin0->nRefs++;
302  }
303 }
Definition: if.h:303
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
void If_ManRestart ( If_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file ifMan.c.

179 {
180  ABC_FREE( p->pMemCi );
181  Vec_PtrClear( p->vCis );
182  Vec_PtrClear( p->vCos );
183  Vec_PtrClear( p->vObjs );
184  Vec_PtrClear( p->vTemp );
186  // create the constant node
187  p->pConst1 = If_ManSetupObj( p );
188  p->pConst1->Type = IF_CONST1;
189  p->pConst1->fPhase = 1;
190  // reset the counter of other nodes
191  p->nObjs[IF_CI] = p->nObjs[IF_CO] = p->nObjs[IF_AND] = 0;
192 }
Vec_Ptr_t * vObjs
Definition: if.h:189
unsigned Type
Definition: if.h:305
Vec_Ptr_t * vTemp
Definition: if.h:191
If_Set_t * pMemCi
Definition: if.h:233
Mem_Fixed_t * pMemObj
Definition: if.h:231
Definition: if.h:68
Definition: if.h:67
Vec_Ptr_t * vCis
Definition: if.h:187
static ABC_NAMESPACE_IMPL_START If_Obj_t * If_ManSetupObj(If_Man_t *p)
DECLARATIONS ///.
Definition: ifMan.c:522
Definition: if.h:66
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Mem_FixedRestart(Mem_Fixed_t *p)
Definition: mem.c:239
int nObjs[IF_VOID]
Definition: if.h:192
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Vec_Ptr_t * vCos
Definition: if.h:188
Definition: if.h:65
unsigned fPhase
Definition: if.h:308
If_Obj_t * pConst1
Definition: if.h:186
Vec_Ptr_t* If_ManReverseOrder ( If_Man_t p)

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

Synopsis [Computes the reverse topological order of nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 363 of file ifUtil.c.

364 {
365  Vec_Ptr_t * vOrder;
366  If_Obj_t * pObj, ** ppStore;
367  int i;
368  // allocate place to store the nodes
369  ppStore = ABC_ALLOC( If_Obj_t *, p->nLevelMax + 1 );
370  memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) );
371  // add the nodes
372  If_ManForEachObj( p, pObj, i )
373  {
374  assert( pObj->Level >= 0 && pObj->Level <= (unsigned)p->nLevelMax );
375  pObj->pCopy = (char *)ppStore[pObj->Level];
376  ppStore[pObj->Level] = pObj;
377  }
378  vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
379  for ( i = p->nLevelMax; i >= 0; i-- )
380  for ( pObj = ppStore[i]; pObj; pObj = (If_Obj_t *)pObj->pCopy )
381  Vec_PtrPush( vOrder, pObj );
382  ABC_FREE( ppStore );
383  // print the order
384 // Vec_PtrForEachEntry( If_Obj_t *, vOrder, pObj, i )
385 // Abc_Print( 1, "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
386  return vOrder;
387 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Definition: if.h:303
int nLevelMax
Definition: if.h:194
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define If_ManForEachObj(p, pObj, i)
Definition: if.h:462
void * pCopy
Definition: if.h:328
unsigned Level
Definition: if.h:315
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
void* If_ManSatBuildFromCell ( char *  pStr,
Vec_Int_t **  pvPiVars,
Vec_Int_t **  pvPoVars,
Ifn_Ntk_t **  ppNtk 
)

Definition at line 622 of file ifTune.c.

623 {
624  Ifn_Ntk_t * p = Ifn_NtkParse( pStr );
625  Ifn_Prepare( p, NULL, p->nInps );
626  *ppNtk = p;
627  if ( p == NULL )
628  return NULL;
629 // Ifn_NtkPrint( p );
630  return Ifn_ManSatBuild( p, pvPiVars, pvPoVars );
631 }
int Ifn_Prepare(Ifn_Ntk_t *p, word *pTruth, int nVars)
FUNCTION DEFINITIONS ///.
Definition: ifTune.c:115
static Llb_Mgr_t * p
Definition: llb3Image.c:950
sat_solver * Ifn_ManSatBuild(Ifn_Ntk_t *p, Vec_Int_t **pvPiVars, Vec_Int_t **pvPoVars)
Definition: ifTune.c:608
int nInps
Definition: ifTune.c:72
Ifn_Ntk_t * Ifn_NtkParse(char *pStr)
Definition: ifTune.c:439
void* If_ManSatBuildXY ( int  nLutSize)

DECLARATIONS ///.

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

FileName [ifSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [SAT-based evaluation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id:
ifSat.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

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

Synopsis [Builds SAT instance for the given structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ifSat.c.

46 {
47  int nMintsL = (1 << nLutSize);
48  int nMintsF = (1 << (2 * nLutSize - 1));
49  int nVars = 2 * nMintsL + nMintsF;
50  int iVarP0 = 0; // LUT0 parameters (total nMintsL)
51  int iVarP1 = nMintsL; // LUT1 parameters (total nMintsL)
52  int m,iVarM = 2 * nMintsL; // MUX vars (total nMintsF)
54  sat_solver_setnvars( p, nVars );
55  for ( m = 0; m < nMintsF; m++ )
57  iVarP0 + m % nMintsL,
58  iVarP1 + 2 * (m / nMintsL) + 1,
59  iVarP1 + 2 * (m / nMintsL),
60  iVarM + m );
61  return p;
62 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int sat_solver_add_mux(sat_solver *pSat, int iVarC, int iVarT, int iVarE, int iVarZ)
Definition: satSolver.h:377
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
void* If_ManSatBuildXYZ ( int  nLutSize)

Definition at line 63 of file ifSat.c.

64 {
65  int nMintsL = (1 << nLutSize);
66  int nMintsF = (1 << (3 * nLutSize - 2));
67  int nVars = 3 * nMintsL + nMintsF;
68  int iVarP0 = 0; // LUT0 parameters (total nMintsL)
69  int iVarP1 = nMintsL; // LUT1 parameters (total nMintsL)
70  int iVarP2 = 2 * nMintsL; // LUT2 parameters (total nMintsL)
71  int m,iVarM = 3 * nMintsL; // MUX vars (total nMintsF)
73  sat_solver_setnvars( p, nVars );
74  for ( m = 0; m < nMintsF; m++ )
76  iVarP0 + m % nMintsL,
77  iVarP1 + (m >> nLutSize) % nMintsL,
78  iVarP2 + 4 * (m >> (2 * nLutSize)) + 0,
79  iVarP2 + 4 * (m >> (2 * nLutSize)) + 1,
80  iVarP2 + 4 * (m >> (2 * nLutSize)) + 2,
81  iVarP2 + 4 * (m >> (2 * nLutSize)) + 3,
82  iVarM + m );
83  return p;
84 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
static int sat_solver_add_mux41(sat_solver *pSat, int iVarC0, int iVarC1, int iVarD0, int iVarD1, int iVarD2, int iVarD3, int iVarZ)
Definition: satSolver.h:423
int If_ManSatCheckXY ( void *  pSat,
int  nLutSize,
word pTruth,
int  nVars,
unsigned  uSet,
word pTBound,
word pTFree,
Vec_Int_t vLits 
)

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

Synopsis [Returns config string for the given truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file ifSat.c.

151 {
152  sat_solver * p = (sat_solver *)pSat;
153  int iBSet, nBSet = 0, pBSet[IF_MAX_FUNC_LUTSIZE];
154  int iSSet, nSSet = 0, pSSet[IF_MAX_FUNC_LUTSIZE];
155  int iFSet, nFSet = 0, pFSet[IF_MAX_FUNC_LUTSIZE];
156  int nMintsL = (1 << nLutSize);
157  int nMintsF = (1 << (2 * nLutSize - 1));
158  int v, Value, m, mNew, nMintsFNew, nMintsLNew;
159  word Res;
160  // collect variable sets
161  Dau_DecSortSet( uSet, nVars, &nBSet, &nSSet, &nFSet );
162  assert( nBSet + nSSet + nFSet == nVars );
163  // check variable bounds
164  assert( nSSet + nBSet <= nLutSize );
165  assert( nLutSize + nSSet + nFSet <= 2*nLutSize - 1 );
166  nMintsFNew = (1 << (nLutSize + nSSet + nFSet));
167  // remap minterms
168  Vec_IntFill( vLits, nMintsF, -1 );
169  for ( m = 0; m < (1 << nVars); m++ )
170  {
171  mNew = iBSet = iSSet = iFSet = 0;
172  for ( v = 0; v < nVars; v++ )
173  {
174  Value = ((uSet >> (v << 1)) & 3);
175  if ( Value == 0 ) // FS
176  {
177  if ( ((m >> v) & 1) )
178  mNew |= 1 << (nLutSize + nSSet + iFSet), pFSet[iFSet] = v;
179  iFSet++;
180  }
181  else if ( Value == 1 ) // BS
182  {
183  if ( ((m >> v) & 1) )
184  mNew |= 1 << (nSSet + iBSet), pBSet[iBSet] = v;
185  iBSet++;
186  }
187  else if ( Value == 3 ) // SS
188  {
189  if ( ((m >> v) & 1) )
190  {
191  mNew |= 1 << iSSet;
192  mNew |= 1 << (nLutSize + iSSet);
193  pSSet[iSSet] = v;
194  }
195  iSSet++;
196  }
197  else assert( Value == 0 );
198  }
199  assert( iBSet == nBSet && iFSet == nFSet );
200  assert( Vec_IntEntry(vLits, mNew) == -1 );
201  Vec_IntWriteEntry( vLits, mNew, Abc_TtGetBit(pTruth, m) );
202  }
203  // find assumptions
204  v = 0;
205  Vec_IntForEachEntry( vLits, Value, m )
206  {
207 // printf( "%d", (Value >= 0) ? Value : 2 );
208  if ( Value >= 0 )
209  Vec_IntWriteEntry( vLits, v++, Abc_Var2Lit(2 * nMintsL + m, !Value) );
210  }
211  Vec_IntShrink( vLits, v );
212 // printf( " %d\n", Vec_IntSize(vLits) );
213  // run SAT solver
214  Value = sat_solver_solve( p, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), 0, 0, 0, 0 );
215  if ( Value != l_True )
216  return 0;
217  if ( pTBound && pTFree )
218  {
219  // collect config
220  assert( nSSet + nBSet <= nLutSize );
221  *pTBound = 0;
222  nMintsLNew = (1 << (nSSet + nBSet));
223  for ( m = 0; m < nMintsLNew; m++ )
224  if ( sat_solver_var_value(p, m) )
225  Abc_TtSetBit( pTBound, m );
226  *pTBound = Abc_Tt6Stretch( *pTBound, nSSet + nBSet );
227  // collect configs
228  assert( nSSet + nFSet + 1 <= nLutSize );
229  *pTFree = 0;
230  nMintsLNew = (1 << (1 + nSSet + nFSet));
231  for ( m = 0; m < nMintsLNew; m++ )
232  if ( sat_solver_var_value(p, nMintsL+m) )
233  Abc_TtSetBit( pTFree, m );
234  *pTFree = Abc_Tt6Stretch( *pTFree, 1 + nSSet + nFSet );
235  if ( nVars != 6 || nLutSize != 4 )
236  return 1;
237  // verify the result
238  Res = If_ManSat6Truth( *pTBound, *pTFree, pBSet, nBSet, pSSet, nSSet, pFSet, nFSet );
239  if ( pTruth[0] != Res )
240  {
241  Dau_DsdPrintFromTruth( pTruth, nVars );
242  Dau_DsdPrintFromTruth( &Res, nVars );
243  Dau_DsdPrintFromTruth( pTBound, nSSet+nBSet );
244  Dau_DsdPrintFromTruth( pTFree, nSSet+nFSet+1 );
245  printf( "Verification failed!\n" );
246  }
247  }
248  return 1;
249 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition: dauDsd.c:1968
#define l_True
Definition: SolverTypes.h:84
static void Abc_TtSetBit(word *p, int i)
Definition: utilTruth.h:150
static int Abc_TtGetBit(word *p, int i)
MACRO DEFINITIONS ///.
Definition: utilTruth.h:149
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
word If_ManSat6Truth(word uBound, word uFree, int *pBSet, int nBSet, int *pSSet, int nSSet, int *pFSet, int nFSet)
Definition: ifSat.c:118
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static word Abc_Tt6Stretch(word t, int nVars)
Definition: utilTruth.h:708
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
void Dau_DecSortSet(unsigned set, int nVars, int *pnUnique, int *pnShared, int *pnFree)
Definition: dauNonDsd.c:371
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
unsigned If_ManSatCheckXYall ( void *  pSat,
int  nLutSize,
word pTruth,
int  nVars,
Vec_Int_t vLits 
)

Definition at line 476 of file ifSat.c.

477 {
478  unsigned uSet = If_ManSatCheckXYall_int( pSat, nLutSize, pTruth, nVars, vLits );
479 // Dau_DecPrintSet( uSet, nVars, 1 );
480  return uSet;
481 }
unsigned If_ManSatCheckXYall_int(void *pSat, int nLutSize, word *pTruth, int nVars, Vec_Int_t *vLits)
Definition: ifSat.c:262
int If_ManSatDeriveGiaFromBits ( void *  pGia,
Ifn_Ntk_t p,
Vec_Int_t vValues,
Vec_Int_t vCover 
)

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

Synopsis [Derive GIA using programmable bits.]

Description []

SideEffects []

SeeAlso []

Definition at line 731 of file ifTune.c.

732 {
733  Gia_Man_t * pNew = (Gia_Man_t *)pGia;
734  int i, Id, k, iLit, iVar = 0, nVarsNew, pVarMap[1000];
735  assert( Gia_ManCiNum(pNew) == p->nInps && p->nParsVIni < 1000 );
736  Gia_ManForEachCiId( pNew, Id, i )
737  pVarMap[i] = Abc_Var2Lit( Id, 0 );
738  for ( i = p->nInps; i < p->nObjs; i++ )
739  {
740  int Type = p->Nodes[i].Type;
741  int nFans = p->Nodes[i].nFanins;
742  int * pFans = p->Nodes[i].Fanins;
743  //int iFanin = p->Nodes[i].iFirst;
744  assert( nFans <= 6 );
745  if ( Type == IFN_DSD_AND )
746  {
747  iLit = 1;
748  for ( k = 0; k < nFans; k++ )
749  iLit = Gia_ManHashAnd( pNew, iLit, pVarMap[pFans[k]] );
750  pVarMap[i] = iLit;
751  }
752  else if ( Type == IFN_DSD_XOR )
753  {
754  iLit = 0;
755  for ( k = 0; k < nFans; k++ )
756  iLit = Gia_ManHashXor( pNew, iLit, pVarMap[pFans[k]] );
757  pVarMap[i] = iLit;
758  }
759  else if ( Type == IFN_DSD_MUX )
760  {
761  assert( nFans == 3 );
762  pVarMap[i] = Gia_ManHashMux( pNew, pVarMap[pFans[0]], pVarMap[pFans[1]], pVarMap[pFans[2]] );
763  }
764  else if ( Type == IFN_DSD_PRIME )
765  {
766  int pFaninLits[16];
767  // collect truth table
768  word uTruth = 0;
769  int nMints = (1 << nFans);
770  for ( k = 0; k < nMints; k++ )
771  if ( Vec_IntEntry( vValues, iVar++ ) )
772  uTruth |= ((word)1 << k);
773  uTruth = Abc_Tt6Stretch( uTruth, nFans );
774  // collect function
775  for ( k = 0; k < nFans; k++ )
776  pFaninLits[k] = pVarMap[pFans[k]];
777  // implement the function
778  nVarsNew = Abc_TtMinBase( &uTruth, pFaninLits, nFans, 6 );
779  if ( nVarsNew == 0 )
780  pVarMap[i] = (int)(uTruth & 1);
781  else
782  {
783  extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
784  Vec_Int_t Leaves = { nVarsNew, nVarsNew, pFaninLits };
785  pVarMap[i] = Kit_TruthToGia( pNew, (unsigned *)&uTruth, nVarsNew, vCover, &Leaves, 1 ); // hashing enabled!!!
786  }
787  }
788  else assert( 0 );
789  }
790  assert( iVar == Vec_IntSize(vValues) );
791  return pVarMap[p->nObjs - 1];
792 }
unsigned nFanins
Definition: ifTune.c:64
int Fanins[IFN_INS]
Definition: ifTune.c:67
Ifn_Obj_t Nodes[2 *IFN_INS]
Definition: ifTune.c:74
static int Abc_TtMinBase(word *pTruth, int *pVars, int nVars, int nVarsAll)
Definition: utilTruth.h:1395
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:658
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int nParsVIni
Definition: ifTune.c:82
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int nInps
Definition: ifTune.c:72
for(p=first;p->value< newval;p=p->next)
#define Gia_ManForEachCiId(p, Id, i)
Definition: gia.h:1018
int nObjs
Definition: ifTune.c:73
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
static word Abc_Tt6Stretch(word t, int nVars)
Definition: utilTruth.h:708
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:80
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
unsigned Type
Definition: ifTune.c:63
int If_ManSatFindCofigBits ( void *  pSat,
Vec_Int_t vPiVars,
Vec_Int_t vPoVars,
word pTruth,
int  nVars,
word  Perm,
int  nInps,
Vec_Int_t vValues 
)

Definition at line 687 of file ifTune.c.

688 {
689  // extract permutation
690  int RetValue, i, pPerm[IF_MAX_FUNC_LUTSIZE];
691  assert( nInps <= IF_MAX_FUNC_LUTSIZE );
692  for ( i = 0; i < nInps; i++ )
693  {
694  pPerm[i] = Abc_TtGetHex( &Perm, i );
695  assert( pPerm[i] < nVars );
696  }
697  // perform SAT check
698  RetValue = Ifn_ManSatCheckOne( (sat_solver *)pSat, vPoVars, pTruth, nVars, pPerm, nInps, vValues );
699  Vec_IntClear( vValues );
700  if ( RetValue == 0 )
701  return 0;
702  Ifn_ManSatDeriveOne( pSat, vPiVars, vValues );
703  return 1;
704 }
void Ifn_ManSatDeriveOne(sat_solver *pSat, Vec_Int_t *vPiVars, Vec_Int_t *vValues)
Definition: ifTune.c:680
int Ifn_ManSatCheckOne(sat_solver *pSat, Vec_Int_t *vPoVars, word *pTruth, int nVars, int *pPerm, int nInps, Vec_Int_t *vLits)
Definition: ifTune.c:651
static int Abc_TtGetHex(word *p, int k)
Definition: utilTruth.h:154
#define IF_MAX_FUNC_LUTSIZE
Definition: if.h:54
static int pPerm[13719]
Definition: rwrTemp.c:32
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void If_ManSatUnbuild ( void *  p)

Definition at line 85 of file ifSat.c.

86 {
87  if ( p )
89 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
float If_ManScanMapping ( If_Man_t p)
float If_ManScanMappingDirect ( If_Man_t p)
float If_ManScanMappingSeq ( If_Man_t p)
void If_ManSetDefaultPars ( If_Par_t pPars)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ifCore.c.

48 {
49  memset( pPars, 0, sizeof(If_Par_t) );
50  pPars->nLutSize = -1;
51  pPars->nCutsMax = 8;
52  pPars->nFlowIters = 1;
53  pPars->nAreaIters = 2;
54  pPars->DelayTarget = -1;
55  pPars->Epsilon = (float)0.005;
56  pPars->fPreprocess = 1;
57  pPars->fArea = 0;
58  pPars->fFancy = 0;
59  pPars->fExpRed = 1;
60  pPars->fLatchPaths = 0;
61  pPars->fEdge = 1;
62  pPars->fPower = 0;
63  pPars->fCutMin = 0;
64  pPars->fBidec = 0;
65  pPars->fVerbose = 0;
66 }
char * memset()
int nLutSize
Definition: if.h:103
Definition: if.h:100
int fVerbose
Definition: if.h:140
int fExpRed
Definition: if.h:116
int nFlowIters
Definition: if.h:105
int fEdge
Definition: if.h:118
int fPreprocess
Definition: if.h:113
int fLatchPaths
Definition: if.h:117
int fBidec
Definition: if.h:125
float Epsilon
Definition: if.h:110
int fFancy
Definition: if.h:115
float DelayTarget
Definition: if.h:109
int nAreaIters
Definition: if.h:106
int fPower
Definition: if.h:119
int fCutMin
Definition: if.h:120
int nCutsMax
Definition: if.h:104
int fArea
Definition: if.h:114
void If_ManSetupCiCutSets ( If_Man_t p)

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

Synopsis [Prepares memory for one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 548 of file ifMan.c.

549 {
550  If_Obj_t * pObj;
551  int i;
552  assert( p->pMemCi == NULL );
553  // create elementary cuts for the CIs
554  If_ManForEachCi( p, pObj, i )
555  If_ManSetupCutTriv( p, &pObj->CutBest, pObj->Id );
556  // create elementary cutsets for the CIs
557  p->pMemCi = (If_Set_t *)ABC_ALLOC( char, If_ManCiNum(p) * (sizeof(If_Set_t) + sizeof(void *)) );
558  If_ManForEachCi( p, pObj, i )
559  {
560  pObj->pCutSet = (If_Set_t *)((char *)p->pMemCi + i * (sizeof(If_Set_t) + sizeof(void *)));
561  pObj->pCutSet->nCuts = 1;
562  pObj->pCutSet->nCutsMax = p->pPars->nCutsMax;
563  pObj->pCutSet->ppCuts = (If_Cut_t **)(pObj->pCutSet + 1);
564  pObj->pCutSet->ppCuts[0] = &pObj->CutBest;
565  }
566 }
If_Set_t * pMemCi
Definition: if.h:233
Definition: if.h:303
Definition: if.h:275
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int If_ManCiNum(If_Man_t *p)
Definition: if.h:360
#define If_ManForEachCi(p, pObj, i)
Definition: if.h:445
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition: ifMan.c:499
Definition: if.h:294
struct If_Set_t_ If_Set_t
Definition: if.h:80
#define assert(ex)
Definition: util_old.h:213
void If_ManSetupCutTriv ( If_Man_t p,
If_Cut_t pCut,
int  ObjId 
)

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

Synopsis [Prepares memory for one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 499 of file ifMan.c.

500 {
501  pCut->fCompl = 0;
502  pCut->nLimit = p->pPars->nLutSize;
503  pCut->nLeaves = 1;
504  pCut->pLeaves[0] = p->pPars->fLiftLeaves? (ObjId << 8) : ObjId;
505  pCut->uSign = If_ObjCutSign( pCut->pLeaves[0] );
506  pCut->iCutFunc = p->pPars->fUseTtPerm ? 3 : (p->pPars->fTruth ? 2: -1);
507  pCut->uMaskFunc = 0;
508  assert( pCut->pLeaves[0] < p->vObjs->nSize );
509 }
Vec_Ptr_t * vObjs
Definition: if.h:189
unsigned nLeaves
Definition: if.h:289
unsigned nLimit
Definition: if.h:288
int nLutSize
Definition: if.h:103
int pLeaves[0]
Definition: if.h:290
int fTruth
Definition: if.h:146
static unsigned If_ObjCutSign(unsigned ObjId)
Definition: if.h:402
If_Par_t * pPars
Definition: if.h:184
int uMaskFunc
Definition: if.h:282
unsigned uSign
Definition: if.h:283
int fUseTtPerm
Definition: if.h:137
#define assert(ex)
Definition: util_old.h:213
unsigned fCompl
Definition: if.h:285
int fLiftLeaves
Definition: if.h:156
int iCutFunc
Definition: if.h:281
If_Set_t* If_ManSetupNodeCutSet ( If_Man_t p,
If_Obj_t pObj 
)

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

Synopsis [Prepares cutset of the node.]

Description [Elementary cutset will be added last.]

SideEffects []

SeeAlso []

Definition at line 579 of file ifMan.c.

580 {
581  assert( If_ObjIsAnd(pObj) );
582  assert( pObj->pCutSet == NULL );
583 // pObj->pCutSet = (If_Set_t *)Mem_FixedEntryFetch( p->pMemSet );
584 // If_ManSetupSet( p, pObj->pCutSet );
585  pObj->pCutSet = If_ManCutSetFetch( p );
586  pObj->pCutSet->nCuts = 0;
587  pObj->pCutSet->nCutsMax = p->pPars->nCutsMax;
588  return pObj->pCutSet;
589 }
If_Set_t * pCutSet
Definition: if.h:332
static If_Set_t * If_ManCutSetFetch(If_Man_t *p)
Definition: ifMan.c:33
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
short nCutsMax
Definition: if.h:296
If_Par_t * pPars
Definition: if.h:184
short nCuts
Definition: if.h:297
#define assert(ex)
Definition: util_old.h:213
int nCutsMax
Definition: if.h:104
void If_ManSetupSetAll ( If_Man_t p,
int  nCrossCut 
)

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

Synopsis [Dereferences cutset of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 675 of file ifMan.c.

676 {
677  If_Set_t * pCutSet;
678  int i, nCutSets;
679  nCutSets = 128 + nCrossCut;
680  p->pFreeList = p->pMemAnd = pCutSet = (If_Set_t *)ABC_ALLOC( char, nCutSets * p->nSetBytes );
681  for ( i = 0; i < nCutSets; i++ )
682  {
683  If_ManSetupSet( p, pCutSet );
684  if ( i == nCutSets - 1 )
685  pCutSet->pNext = NULL;
686  else
687  pCutSet->pNext = (If_Set_t *)( (char *)pCutSet + p->nSetBytes );
688  pCutSet = pCutSet->pNext;
689  }
690  assert( pCutSet == NULL );
691 
692  if ( p->pPars->fVerbose )
693  {
694  Abc_Print( 1, "Node = %7d. Ch = %5d. Total mem = %7.2f MB. Peak cut mem = %7.2f MB.\n",
695  If_ManAndNum(p), p->nChoices,
696  1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
697  1.0 * p->nSetBytes * nCrossCut / (1<<20) );
698  }
699 // Abc_Print( 1, "Cross cut = %d.\n", nCrossCut );
700 
701 }
static int If_ManAndNum(If_Man_t *p)
Definition: if.h:362
int fVerbose
Definition: if.h:140
int nChoices
Definition: if.h:207
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void If_ManSetupSet(If_Man_t *p, If_Set_t *pSet)
Definition: ifMan.c:471
int nSetBytes
Definition: if.h:230
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nObjBytes
Definition: if.h:228
static int If_ManObjNum(If_Man_t *p)
Definition: if.h:363
If_Par_t * pPars
Definition: if.h:184
Definition: if.h:294
#define assert(ex)
Definition: util_old.h:213
If_Set_t * pMemAnd
Definition: if.h:234
If_Set_t * pFreeList
Definition: if.h:235
If_Set_t * pNext
Definition: if.h:298
If_Man_t* If_ManStart ( If_Par_t pPars)

FUNCTION DEFINITIONS ///.

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

Synopsis [Starts the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file ifMan.c.

51 {
52  If_Man_t * p; int v;
53  assert( !pPars->fUseDsd || !pPars->fUseTtPerm );
54  // start the manager
55  p = ABC_ALLOC( If_Man_t, 1 );
56  memset( p, 0, sizeof(If_Man_t) );
57  p->pPars = pPars;
58  p->fEpsilon = pPars->Epsilon;
59  // allocate arrays for nodes
60  p->vCis = Vec_PtrAlloc( 100 );
61  p->vCos = Vec_PtrAlloc( 100 );
62  p->vObjs = Vec_PtrAlloc( 100 );
63  p->vTemp = Vec_PtrAlloc( 100 );
64  // prepare the memory manager
65  if ( p->pPars->fTruth )
66  {
67  for ( v = 0; v <= p->pPars->nLutSize; v++ )
68  p->nTruth6Words[v] = Abc_Truth6WordNum( v );
69  for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
70  p->vTtMem[v] = Vec_MemAllocForTT( v, pPars->fUseTtPerm );
71  for ( v = 0; v < 6; v++ )
72  p->vTtMem[v] = p->vTtMem[6];
73  if ( p->pPars->fDelayOpt || pPars->nGateSize > 0 )
74  {
75  for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
76  p->vTtIsops[v] = Vec_WecAlloc( 1000 );
77  for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
78  Vec_WecInit( p->vTtIsops[v], 2 );
79  for ( v = 0; v < 6; v++ )
80  p->vTtIsops[v] = p->vTtIsops[6];
81  }
82  if ( pPars->fDelayOpt || pPars->nGateSize > 0 || pPars->fDsdBalance )
83  {
84  p->vCover = Vec_IntAlloc( 0 );
85  p->vArray = Vec_IntAlloc( 1000 );
86  }
87  }
89  p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords);
90  p->nCutBytes = sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords);
91  p->nSetBytes = sizeof(If_Set_t) + (sizeof(If_Cut_t *) + p->nCutBytes) * (p->pPars->nCutsMax + 1);
92  p->pMemObj = Mem_FixedStart( p->nObjBytes );
93  // report expected memory usage
94  if ( p->pPars->fVerbose )
95  Abc_Print( 1, "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d. CutMin = %s\n",
96  p->pPars->nLutSize, 8 * p->nTruth6Words[p->pPars->nLutSize], p->nCutBytes, p->nObjBytes, p->nSetBytes, p->pPars->fCutMin? "yes":"no" );
97  // room for temporary truth tables
98  p->puTemp[0] = p->pPars->fTruth? ABC_ALLOC( unsigned, 8 * p->nTruth6Words[p->pPars->nLutSize] ) : NULL;
99  p->puTemp[1] = p->puTemp[0] + p->nTruth6Words[p->pPars->nLutSize]*2;
100  p->puTemp[2] = p->puTemp[1] + p->nTruth6Words[p->pPars->nLutSize]*2;
101  p->puTemp[3] = p->puTemp[2] + p->nTruth6Words[p->pPars->nLutSize]*2;
102  p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words[p->pPars->nLutSize] ) : NULL;
103  if ( pPars->fUseDsd )
104  {
105  for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
106  {
107  p->vTtDsds[v] = Vec_IntAlloc( 1000 );
108  Vec_IntPush( p->vTtDsds[v], 0 );
109  Vec_IntPush( p->vTtDsds[v], 2 );
110  p->vTtPerms[v] = Vec_StrAlloc( 10000 );
111  Vec_StrFill( p->vTtPerms[v], 2 * v, IF_BIG_CHAR );
112  Vec_StrWriteEntry( p->vTtPerms[v], v, 0 );
113  }
114  for ( v = 0; v < 6; v++ )
115  {
116  p->vTtDsds[v] = p->vTtDsds[6];
117  p->vTtPerms[v] = p->vTtPerms[6];
118  }
119  }
120  if ( pPars->fUseTtPerm )
121  {
122  p->vPairHash = Hash_IntManStart( 10000 );
123  p->vPairPerms = Vec_StrAlloc( 10000 );
124  Vec_StrFill( p->vPairPerms, p->pPars->nLutSize, 0 );
125  p->vPairRes = Vec_IntAlloc( 1000 );
126  Vec_IntPush( p->vPairRes, -1 );
127  }
128  if ( pPars->fUseCofVars )
129  {
130  for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
131  {
132  p->vTtVars[v] = Vec_StrAlloc( 1000 );
133  Vec_StrPush( p->vTtVars[v], 0 );
134  Vec_StrPush( p->vTtVars[v], 0 );
135  }
136  for ( v = 0; v < 6; v++ )
137  p->vTtVars[v] = p->vTtVars[6];
138  }
139  if ( pPars->fUseAndVars )
140  {
141  for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
142  {
143  p->vTtDecs[v] = Vec_IntAlloc( 1000 );
144  Vec_IntPush( p->vTtDecs[v], 0 );
145  Vec_IntPush( p->vTtDecs[v], 0 );
146  }
147  for ( v = 0; v < 6; v++ )
148  p->vTtDecs[v] = p->vTtDecs[6];
149  }
150  if ( pPars->fUseBat )
151  {
152 // abctime clk = Abc_Clock();
153  extern int Bat_ManCellFuncLookup( void * pMan, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
154  extern void Bat_ManFuncSetupTable();
155  pPars->pFuncCell = (int (*) (If_Man_t *, unsigned *, int, int, char *))Bat_ManCellFuncLookup;
157 // Abc_PrintTime( 1, "Setup time", Abc_Clock() - clk );
158  }
159  // create the constant node
160  p->pConst1 = If_ManSetupObj( p );
161  p->pConst1->Type = IF_CONST1;
162  p->pConst1->fPhase = 1;
163  p->nObjs[IF_CONST1]++;
164  return p;
165 }
int nTruth6Words[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:226
char * memset()
Vec_Ptr_t * vObjs
Definition: if.h:189
static Hash_IntMan_t * Hash_IntManStart(int nSize)
FUNCTION DEFINITIONS ///.
Definition: vecHash.h:86
unsigned Type
Definition: if.h:305
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
Vec_Str_t * vTtVars[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:248
int nLutSize
Definition: if.h:103
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:245
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:244
Vec_Int_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:249
Vec_Ptr_t * vTemp
Definition: if.h:191
#define IF_BIG_CHAR
Definition: if.h:60
Definition: if.h:275
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
int fVerbose
Definition: if.h:140
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:247
ABC_NAMESPACE_IMPL_START void Bat_ManFuncSetupTable()
DECLARATIONS ///.
Definition: ifMatch2.c:45
Hash_IntMan_t * vPairHash
Definition: if.h:250
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int fUseCofVars
Definition: if.h:135
Mem_Fixed_t * pMemObj
Definition: if.h:231
struct If_Obj_t_ If_Obj_t
Definition: if.h:78
int nGateSize
Definition: if.h:107
Mem_Fixed_t * Mem_FixedStart(int nEntrySize)
FUNCTION DEFINITIONS ///.
Definition: mem.c:100
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
Vec_Ptr_t * vCis
Definition: if.h:187
int fUsePerm
Definition: if.h:147
unsigned * puTemp[4]
Definition: if.h:203
int fDsdBalance
Definition: if.h:123
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int fTruth
Definition: if.h:146
static Vec_Mem_t * Vec_MemAllocForTT(int nVars, int fCompl)
Definition: vecMem.h:378
Definition: if.h:180
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static ABC_NAMESPACE_IMPL_START If_Obj_t * If_ManSetupObj(If_Man_t *p)
DECLARATIONS ///.
Definition: ifMan.c:522
static void Vec_StrFill(Vec_Str_t *p, int nSize, char Fill)
Definition: vecStr.h:423
if(last==0)
Definition: sparse_int.h:34
Vec_Int_t * vArray
Definition: if.h:215
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int nSetBytes
Definition: if.h:230
word * puTempW
Definition: if.h:204
float Epsilon
Definition: if.h:110
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int fUseAndVars
Definition: if.h:136
float fEpsilon
Definition: if.h:195
Vec_Int_t * vCover
Definition: if.h:214
int nObjBytes
Definition: if.h:228
Vec_Int_t * vPairRes
Definition: if.h:251
int nPermWords
Definition: if.h:227
int fUseDsd
Definition: if.h:133
If_Par_t * pPars
Definition: if.h:184
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:246
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int(* pFuncCell)(If_Man_t *, unsigned *, int, int, char *)
Definition: if.h:165
static int If_CutPermWords(int nVarsMax)
Definition: if.h:395
struct If_Cut_t_ If_Cut_t
Definition: if.h:79
int fDelayOpt
Definition: if.h:121
int fUseBat
Definition: if.h:126
int fCutMin
Definition: if.h:120
struct If_Set_t_ If_Set_t
Definition: if.h:80
int fUseTtPerm
Definition: if.h:137
int Bat_ManCellFuncLookup(void *pMan, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
Definition: ifMatch2.c:51
int nObjs[IF_VOID]
Definition: if.h:192
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t * vCos
Definition: if.h:188
int nCutBytes
Definition: if.h:229
int nCutsMax
Definition: if.h:104
Definition: if.h:65
unsigned fPhase
Definition: if.h:308
If_Obj_t * pConst1
Definition: if.h:186
Vec_Str_t * vPairPerms
Definition: if.h:252
static void Vec_WecInit(Vec_Wec_t *p, int nSize)
Definition: vecWec.h:125
void If_ManStop ( If_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file ifMan.c.

206 {
207  extern void If_ManCacheAnalize( If_Man_t * p );
208  int i;
209  if ( p->pPars->fVerbose && p->vCutData )
210  If_ManCacheAnalize( p );
211  if ( p->pPars->fVerbose && p->pPars->fTruth )
212  {
213  int nUnique = 0, nMemTotal = 0;
214  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
215  nUnique += Vec_MemEntryNum(p->vTtMem[i]);
216  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
217  nMemTotal += (int)Vec_MemMemory(p->vTtMem[i]);
218  printf( "Unique truth tables = %d Memory = %.2f MB ", nUnique, 1.0 * nMemTotal / (1<<20) );
219  Abc_PrintTime( 1, "Time", p->timeCache[4] );
220  if ( p->nCacheMisses )
221  {
222  printf( "Cache hits = %d. Cache misses = %d (%.2f %%)\n", p->nCacheHits, p->nCacheMisses, 100.0 * p->nCacheMisses / (p->nCacheHits + p->nCacheMisses) );
223  Abc_PrintTime( 1, "Non-DSD ", p->timeCache[0] );
224  Abc_PrintTime( 1, "DSD hits ", p->timeCache[1] );
225  Abc_PrintTime( 1, "DSD misses", p->timeCache[2] );
226  Abc_PrintTime( 1, "TOTAL ", p->timeCache[0] + p->timeCache[1] + p->timeCache[2] );
227  Abc_PrintTime( 1, "Canon ", p->timeCache[3] );
228  }
229  }
230  if ( p->pPars->fVerbose && p->nCutsUselessAll )
231  {
232  for ( i = 0; i <= 16; i++ )
233  if ( p->nCutsUseless[i] )
234  Abc_Print( 1, "Useless cuts %2d = %9d (out of %9d) (%6.2f %%)\n", i, p->nCutsUseless[i], p->nCutsCount[i], 100.0*p->nCutsUseless[i]/Abc_MaxInt(p->nCutsCount[i],1) );
235  Abc_Print( 1, "Useless cuts all = %9d (out of %9d) (%6.2f %%)\n", p->nCutsUselessAll, p->nCutsCountAll, 100.0*p->nCutsUselessAll/Abc_MaxInt(p->nCutsCountAll,1) );
236  }
237 // if ( p->pPars->fVerbose && p->nCuts5 )
238 // Abc_Print( 1, "Statistics about 5-cuts: Total = %d Non-decomposable = %d (%.2f %%)\n", p->nCuts5, p->nCuts5-p->nCuts5a, 100.0*(p->nCuts5-p->nCuts5a)/p->nCuts5 );
239  if ( p->pIfDsdMan )
240  p->pIfDsdMan = NULL;
241  if ( p->pPars->fUseDsd && (p->nCountNonDec[0] || p->nCountNonDec[1]) )
242  printf( "NonDec0 = %d. NonDec1 = %d.\n", p->nCountNonDec[0], p->nCountNonDec[1] );
243  Vec_IntFreeP( &p->vCoAttrs );
244  Vec_PtrFree( p->vCis );
245  Vec_PtrFree( p->vCos );
246  Vec_PtrFree( p->vObjs );
247  Vec_PtrFree( p->vTemp );
248  Vec_IntFreeP( &p->vCover );
249  Vec_IntFreeP( &p->vArray );
250  Vec_WrdFreeP( &p->vAnds );
251  Vec_WrdFreeP( &p->vAndGate );
252  Vec_WrdFreeP( &p->vOrGate );
253  Vec_PtrFreeP( &p->vObjsRev );
254  Vec_PtrFreeP( &p->vLatchOrder );
255  Vec_IntFreeP( &p->vLags );
256  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
257  Vec_IntFreeP( &p->vTtDsds[i] );
258  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
259  Vec_StrFreeP( &p->vTtPerms[i] );
260  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
261  Vec_StrFreeP( &p->vTtVars[i] );
262  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
263  Vec_IntFreeP( &p->vTtDecs[i] );
264  Vec_IntFreeP( &p->vCutData );
265  Vec_IntFreeP( &p->vPairRes );
266  Vec_StrFreeP( &p->vPairPerms );
267  if ( p->vPairHash )
269  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
270  Vec_MemHashFree( p->vTtMem[i] );
271  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
272  Vec_MemFreeP( &p->vTtMem[i] );
273  for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
274  Vec_WecFreeP( &p->vTtIsops[i] );
275  Mem_FixedStop( p->pMemObj, 0 );
276  ABC_FREE( p->pMemCi );
277  ABC_FREE( p->pMemAnd );
278  ABC_FREE( p->puTemp[0] );
279  ABC_FREE( p->puTempW );
280  // free pars memory
281  ABC_FREE( p->pPars->pTimesArr );
282  ABC_FREE( p->pPars->pTimesReq );
283  if ( p->pManTim )
284  Tim_ManStop( p->pManTim );
285  if ( p->vSwitching )
286  Vec_IntFree( p->vSwitching );
287  if ( p->pPars->fUseBat )
288  {
289  extern void Bat_ManFuncSetdownTable();
291  }
292  // hash table
293 // if ( p->pPars->fVerbose && p->nTableEntries[0] )
294 // printf( "Hash table 2: Entries = %7d. Size = %7d.\n", p->nTableEntries[0], p->nTableSize[0] );
295 // if ( p->pPars->fVerbose && p->nTableEntries[1] )
296 // printf( "Hash table 3: Entries = %7d. Size = %7d.\n", p->nTableEntries[1], p->nTableSize[1] );
297  ABC_FREE( p->pHashTable[0] );
298  ABC_FREE( p->pHashTable[1] );
299  if ( p->pMemEntries )
300  Mem_FixedStop( p->pMemEntries, 0 );
301  ABC_FREE( p->pName );
302  ABC_FREE( p );
303 }
Vec_Ptr_t * vObjs
Definition: if.h:189
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
Vec_Str_t * vTtVars[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:248
int nLutSize
Definition: if.h:103
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:245
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:244
Vec_Int_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:249
Vec_Ptr_t * vTemp
Definition: if.h:191
If_Set_t * pMemCi
Definition: if.h:233
Vec_Ptr_t * vObjsRev
Definition: if.h:190
int fVerbose
Definition: if.h:140
int nCutsCountAll
Definition: if.h:240
static int Vec_MemEntryNum(Vec_Mem_t *p)
Definition: vecMem.h:151
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:247
Hash_IntMan_t * vPairHash
Definition: if.h:250
void Mem_FixedStop(Mem_Fixed_t *p, int fVerbose)
Definition: mem.c:139
void If_ManCacheAnalize(If_Man_t *p)
Definition: ifCache.c:70
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
Vec_Int_t * vSwitching
Definition: if.h:208
static void Vec_WrdFreeP(Vec_Wrd_t **p)
Definition: vecWrd.h:277
int nCacheMisses
Definition: if.h:256
void Bat_ManFuncSetdownTable()
Definition: ifMatch2.c:48
Mem_Fixed_t * pMemObj
Definition: if.h:231
Vec_Wrd_t * vAndGate
Definition: if.h:218
Tim_Man_t * pManTim
Definition: if.h:263
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int nCutsUseless[32]
Definition: if.h:238
Vec_Ptr_t * vCis
Definition: if.h:187
char * pName
Definition: if.h:182
void ** pHashTable[2]
Definition: if.h:268
unsigned * puTemp[4]
Definition: if.h:203
Vec_Wrd_t * vAnds
Definition: if.h:216
int fTruth
Definition: if.h:146
Definition: if.h:180
static void Vec_MemFreeP(Vec_Mem_t **p)
Definition: vecMem.h:105
static void Hash_IntManStop(Hash_IntMan_t *p)
Definition: vecHash.h:95
static double Vec_MemMemory(Vec_Mem_t *p)
Definition: vecMem.h:175
int nCutsUselessAll
Definition: if.h:241
Vec_Int_t * vArray
Definition: if.h:215
float * pTimesArr
Definition: if.h:161
Vec_Int_t * vCutData
Definition: if.h:260
void Tim_ManStop(Tim_Man_t *p)
Definition: timMan.c:375
word * puTempW
Definition: if.h:204
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
int nCountNonDec[2]
Definition: if.h:259
Mem_Fixed_t * pMemEntries
Definition: if.h:269
float * pTimesReq
Definition: if.h:162
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
Vec_Int_t * vCover
Definition: if.h:214
abctime timeCache[6]
Definition: if.h:257
int nCacheHits
Definition: if.h:255
Vec_Int_t * vPairRes
Definition: if.h:251
int fUseDsd
Definition: if.h:133
Vec_Wrd_t * vOrGate
Definition: if.h:217
If_Par_t * pPars
Definition: if.h:184
Vec_Int_t * vLags
Definition: if.h:221
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:246
Vec_Int_t * vCoAttrs
Definition: if.h:264
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
int fUseBat
Definition: if.h:126
static void Vec_WecFreeP(Vec_Wec_t **p)
Definition: vecWec.h:350
static void Vec_MemHashFree(Vec_Mem_t *p)
Definition: vecMem.h:311
Vec_Ptr_t * vCos
Definition: if.h:188
int nCutsCount[32]
Definition: if.h:239
Vec_Ptr_t * vLatchOrder
Definition: if.h:220
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
If_Set_t * pMemAnd
Definition: if.h:234
Vec_Str_t * vPairPerms
Definition: if.h:252
static void Vec_StrFreeP(Vec_Str_t **p)
Definition: vecStr.h:233
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static If_Obj_t* If_Not ( If_Obj_t p)
inlinestatic

Definition at line 356 of file if.h.

356 { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
Definition: if.h:303
static If_Obj_t* If_NotCond ( If_Obj_t p,
int  c 
)
inlinestatic

Definition at line 357 of file if.h.

357 { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
Definition: if.h:303
static float If_ObjArrTime ( If_Obj_t pObj)
inlinestatic

Definition at line 405 of file if.h.

405 { return If_ObjCutBest(pObj)->Delay; }
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
float Delay
Definition: if.h:280
static void* If_ObjCopy ( If_Obj_t pObj)
inlinestatic

Definition at line 384 of file if.h.

384 { return pObj->pCopy; }
void * pCopy
Definition: if.h:328
static If_Cut_t* If_ObjCutBest ( If_Obj_t pObj)
inlinestatic

Definition at line 401 of file if.h.

401 { return &pObj->CutBest; }
If_Cut_t CutBest
Definition: if.h:333
static unsigned If_ObjCutSign ( unsigned  ObjId)
inlinestatic

Definition at line 402 of file if.h.

402 { return (1 << (ObjId % 31)); }
static unsigned If_ObjCutSignCompute ( If_Cut_t p)
inlinestatic

Definition at line 403 of file if.h.

403 { unsigned s = 0; int i; for ( i = 0; i < If_CutLeaveNum(p); i++ ) s |= If_ObjCutSign(p->pLeaves[i]); return s; }
static int If_CutLeaveNum(If_Cut_t *pCut)
Definition: if.h:390
int pLeaves[0]
Definition: if.h:290
static unsigned If_ObjCutSign(unsigned ObjId)
Definition: if.h:402
static If_Obj_t* If_ObjFanin0 ( If_Obj_t pObj)
inlinestatic

Definition at line 380 of file if.h.

380 { return pObj->pFanin0; }
If_Obj_t * pFanin0
Definition: if.h:321
static If_Obj_t* If_ObjFanin1 ( If_Obj_t pObj)
inlinestatic

Definition at line 381 of file if.h.

381 { return pObj->pFanin1; }
If_Obj_t * pFanin1
Definition: if.h:322
static int If_ObjFaninC0 ( If_Obj_t pObj)
inlinestatic

Definition at line 382 of file if.h.

382 { return pObj->fCompl0; }
unsigned fCompl0
Definition: if.h:306
static int If_ObjFaninC1 ( If_Obj_t pObj)
inlinestatic

Definition at line 383 of file if.h.

383 { return pObj->fCompl1; }
unsigned fCompl1
Definition: if.h:307
static int If_ObjId ( If_Obj_t pObj)
inlinestatic

Definition at line 379 of file if.h.

379 { return pObj->Id; }
int Id
Definition: if.h:316
static int If_ObjIsAnd ( If_Obj_t pObj)
inlinestatic

Definition at line 377 of file if.h.

377 { return pObj->Type == IF_AND; }
unsigned Type
Definition: if.h:305
Definition: if.h:68
static int If_ObjIsCi ( If_Obj_t pObj)
inlinestatic

Definition at line 373 of file if.h.

373 { return pObj->Type == IF_CI; }
unsigned Type
Definition: if.h:305
Definition: if.h:66
static int If_ObjIsCo ( If_Obj_t pObj)
inlinestatic

Definition at line 374 of file if.h.

374 { return pObj->Type == IF_CO; }
unsigned Type
Definition: if.h:305
Definition: if.h:67
static int If_ObjIsConst1 ( If_Obj_t pObj)
inlinestatic

Definition at line 372 of file if.h.

372 { return pObj->Type == IF_CONST1; }
unsigned Type
Definition: if.h:305
Definition: if.h:65
static int If_ObjIsLatch ( If_Obj_t pObj)
inlinestatic

Definition at line 376 of file if.h.

376 { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL; }
If_Obj_t * pFanin0
Definition: if.h:321
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static int If_ObjIsTerm ( If_Obj_t pObj)
inlinestatic

Definition at line 375 of file if.h.

375 { return pObj->Type == IF_CI || pObj->Type == IF_CO; }
unsigned Type
Definition: if.h:305
Definition: if.h:67
Definition: if.h:66
static int If_ObjLevel ( If_Obj_t pObj)
inlinestatic

Definition at line 385 of file if.h.

385 { return pObj->Level; }
unsigned Level
Definition: if.h:315
static float If_ObjLValue ( If_Obj_t pObj)
inlinestatic

Definition at line 408 of file if.h.

408 { return pObj->LValue; }
float LValue
Definition: if.h:326
void If_ObjPerformMappingAnd ( If_Man_t p,
If_Obj_t pObj,
int  Mode,
int  fPreprocess,
int  fFirst 
)

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

Synopsis [Finds the best cut for the given node.]

Description [Mapping modes: delay (0), area flow (1), area (2).]

SideEffects []

SeeAlso []

Definition at line 95 of file ifMap.c.

96 {
97  If_Set_t * pCutSet;
98  If_Cut_t * pCut0, * pCut1, * pCut;
99  If_Cut_t * pCut0R, * pCut1R;
100  int fFunc0R, fFunc1R;
101  int i, k, v, iCutDsd, fChange;
102  int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->pLutStruct != NULL;
103  assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
104  assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
105 
106  // prepare
107  if ( Mode == 0 )
108  pObj->EstRefs = (float)pObj->nRefs;
109  else if ( Mode == 1 )
110  pObj->EstRefs = (float)((2.0 * pObj->EstRefs + pObj->nRefs) / 3.0);
111  // deref the selected cut
112  if ( Mode && pObj->nRefs > 0 )
113  If_CutAreaDeref( p, If_ObjCutBest(pObj) );
114 
115  // prepare the cutset
116  pCutSet = If_ManSetupNodeCutSet( p, pObj );
117 
118  // get the current assigned best cut
119  pCut = If_ObjCutBest(pObj);
120  if ( !fFirst )
121  {
122  // recompute the parameters of the best cut
123  if ( p->pPars->fDelayOpt )
124  pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
125  else if ( p->pPars->fDsdBalance )
126  pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
127  else if ( p->pPars->fUserRecLib )
128  pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
129  else if ( p->pPars->fDelayOptLut )
130  pCut->Delay = If_CutLutBalanceEval( p, pCut );
131  else if( p->pPars->nGateSize > 0 )
132  pCut->Delay = If_CutDelaySop( p, pCut );
133  else
134  pCut->Delay = If_CutDelay( p, pObj, pCut );
135  assert( pCut->Delay != -1 );
136 // assert( pCut->Delay <= pObj->Required + p->fEpsilon );
137  if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
138  Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
139  pObj->Id, pCut->Delay, pObj->Required + p->fEpsilon );
140  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
141  if ( p->pPars->fEdge )
142  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
143  if ( p->pPars->fPower )
144  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
145  // save the best cut from the previous iteration
146  if ( !fPreprocess )
147  If_CutCopy( p, pCutSet->ppCuts[pCutSet->nCuts++], pCut );
148  }
149 
150  // generate cuts
151  If_ObjForEachCut( pObj->pFanin0, pCut0, i )
152  If_ObjForEachCut( pObj->pFanin1, pCut1, k )
153  {
154  // get the next free cut
155  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
156  pCut = pCutSet->ppCuts[pCutSet->nCuts];
157  // make sure K-feasible cut exists
158  if ( If_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->pPars->nLutSize )
159  continue;
160 
161  pCut0R = pCut0;
162  pCut1R = pCut1;
163  fFunc0R = pCut0->iCutFunc ^ pCut0->fCompl ^ pObj->fCompl0;
164  fFunc1R = pCut1->iCutFunc ^ pCut1->fCompl ^ pObj->fCompl1;
165  if ( !p->pPars->fUseTtPerm || pCut0->nLeaves > pCut1->nLeaves || (pCut0->nLeaves == pCut1->nLeaves && fFunc0R > fFunc1R) )
166  {
167  }
168  else
169  {
170  ABC_SWAP( If_Cut_t *, pCut0R, pCut1R );
171  ABC_SWAP( int, fFunc0R, fFunc1R );
172  }
173 
174  // merge the cuts
175  if ( p->pPars->fUseTtPerm )
176  {
177  if ( !If_CutMerge( p, pCut0R, pCut1R, pCut ) )
178  continue;
179  }
180  else
181  {
182  if ( !If_CutMergeOrdered( p, pCut0, pCut1, pCut ) )
183  continue;
184  }
185  if ( pObj->fSpec && pCut->nLeaves == (unsigned)p->pPars->nLutSize )
186  continue;
187  p->nCutsMerged++;
188  p->nCutsTotal++;
189  // check if this cut is contained in any of the available cuts
190  if ( !p->pPars->fSkipCutFilter && If_CutFilter( pCutSet, pCut, fSave0 ) )
191  continue;
192  // compute the truth table
193  pCut->iCutFunc = -1;
194  pCut->fCompl = 0;
195  if ( p->pPars->fTruth )
196  {
197 // int nShared = pCut0->nLeaves + pCut1->nLeaves - pCut->nLeaves;
198  abctime clk = 0;
199  if ( p->pPars->fVerbose )
200  clk = Abc_Clock();
201  if ( p->pPars->fUseTtPerm )
202  fChange = If_CutComputeTruthPerm( p, pCut, pCut0R, pCut1R, fFunc0R, fFunc1R );
203  else
204  fChange = If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
205  if ( p->pPars->fVerbose )
206  p->timeCache[4] += Abc_Clock() - clk;
207  if ( !p->pPars->fSkipCutFilter && fChange && If_CutFilter( pCutSet, pCut, fSave0 ) )
208  continue;
209  if ( p->pPars->fUseDsd )
210  {
211  extern void If_ManCacheRecord( If_Man_t * p, int iDsd0, int iDsd1, int nShared, int iDsd );
212  int truthId = Abc_Lit2Var(pCut->iCutFunc);
213  if ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) || Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId) == -1 )
214  {
215  while ( truthId >= Vec_IntSize(p->vTtDsds[pCut->nLeaves]) )
216  {
217  Vec_IntPush( p->vTtDsds[pCut->nLeaves], -1 );
218  for ( v = 0; v < Abc_MaxInt(6, pCut->nLeaves); v++ )
219  Vec_StrPush( p->vTtPerms[pCut->nLeaves], IF_BIG_CHAR );
220  }
221  iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthWR(p, pCut), pCut->nLeaves, (unsigned char *)If_CutDsdPerm(p, pCut), p->pPars->pLutStruct );
222  Vec_IntWriteEntry( p->vTtDsds[pCut->nLeaves], truthId, iCutDsd );
223  }
224  assert( If_DsdManSuppSize(p->pIfDsdMan, If_CutDsdLit(p, pCut)) == (int)pCut->nLeaves );
225  //If_ManCacheRecord( p, If_CutDsdLit(p, pCut0), If_CutDsdLit(p, pCut1), nShared, If_CutDsdLit(p, pCut) );
226  }
227  // run user functions
228  pCut->fUseless = 0;
229  if ( p->pPars->pFuncCell )
230  {
231  assert( p->pPars->fUseTtPerm == 0 );
232  assert( pCut->nLimit >= 4 && pCut->nLimit <= 16 );
233  if ( p->pPars->fUseDsd )
234  pCut->fUseless = If_DsdManCheckDec( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
235  else
236  pCut->fUseless = !p->pPars->pFuncCell( p, If_CutTruth(p, pCut), Abc_MaxInt(6, pCut->nLeaves), pCut->nLeaves, p->pPars->pLutStruct );
237  p->nCutsUselessAll += pCut->fUseless;
238  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
239  p->nCutsCountAll++;
240  p->nCutsCount[pCut->nLeaves]++;
241  // skip 5-input cuts, which cannot be decomposed
242  if ( (p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u) && pCut->nLeaves == 5 && pCut->nLimit == 5 )
243  {
244  extern int If_CluCheckDecInAny( word t, int nVars );
245  extern int If_CluCheckDecOut( word t, int nVars );
246  unsigned TruthU = *If_CutTruth(p, pCut);
247  word Truth = (((word)TruthU << 32) | (word)TruthU);
248  p->nCuts5++;
249  if ( If_CluCheckDecInAny( Truth, 5 ) )
250  p->nCuts5a++;
251  else
252  continue;
253  }
254  else if ( p->pPars->fVerbose && pCut->nLeaves == 5 )
255  {
256  extern int If_CluCheckDecInAny( word t, int nVars );
257  extern int If_CluCheckDecOut( word t, int nVars );
258  unsigned TruthU = *If_CutTruth(p, pCut);
259  word Truth = (((word)TruthU << 32) | (word)TruthU);
260  p->nCuts5++;
261  if ( If_CluCheckDecInAny( Truth, 5 ) || If_CluCheckDecOut( Truth, 5 ) )
262  p->nCuts5a++;
263  }
264  }
265  else if ( p->pPars->fUseDsdTune )
266  {
267  pCut->fUseless = If_DsdManReadMark( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
268  p->nCutsUselessAll += pCut->fUseless;
269  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
270  p->nCutsCountAll++;
271  p->nCutsCount[pCut->nLeaves]++;
272  }
273  else
274  {
275  if ( p->pPars->fUseAndVars )
276  {
277  int iDecMask = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
278  if ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) || Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId) == -1 )
279  {
280  while ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) )
281  Vec_IntPush( p->vTtDecs[pCut->nLeaves], -1 );
282  if ( (int)pCut->nLeaves > p->pPars->nLutSize / 2 )
283  iDecMask = Abc_TtProcessBiDec( If_CutTruthW(p, pCut), (int)pCut->nLeaves, p->pPars->nLutSize / 2 );
284  else
285  iDecMask = 0;
286  Vec_IntWriteEntry( p->vTtDecs[pCut->nLeaves], truthId, iDecMask );
287  }
288  iDecMask = Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId);
289  assert( iDecMask >= 0 );
290  pCut->fUseless = (int)(iDecMask == 0 && (int)pCut->nLeaves > p->pPars->nLutSize / 2);
291  p->nCutsUselessAll += pCut->fUseless;
292  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
293  p->nCutsCountAll++;
294  p->nCutsCount[pCut->nLeaves]++;
295  }
296  if ( p->pPars->fUseCofVars && (!p->pPars->fUseAndVars || pCut->fUseless) )
297  {
298  int iCofVar = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
299  if ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) || Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId) == (char)-1 )
300  {
301  while ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) )
302  Vec_StrPush( p->vTtVars[pCut->nLeaves], (char)-1 );
303  iCofVar = Abc_TtCheckCondDep( If_CutTruthWR(p, pCut), pCut->nLeaves, p->pPars->nLutSize / 2 );
304  Vec_StrWriteEntry( p->vTtVars[pCut->nLeaves], truthId, (char)iCofVar );
305  }
306  iCofVar = Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId);
307  assert( iCofVar >= 0 && iCofVar <= (int)pCut->nLeaves );
308  pCut->fUseless = (int)(iCofVar == (int)pCut->nLeaves && pCut->nLeaves > 0);
309  p->nCutsUselessAll += pCut->fUseless;
310  p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
311  p->nCutsCountAll++;
312  p->nCutsCount[pCut->nLeaves]++;
313  }
314  }
315  }
316 
317  // compute the application-specific cost and depth
318  pCut->fUser = (p->pPars->pFuncCost != NULL);
319  pCut->Cost = p->pPars->pFuncCost? p->pPars->pFuncCost(p, pCut) : 0;
320  if ( pCut->Cost == IF_COST_MAX )
321  continue;
322  // check if the cut satisfies the required times
323  if ( p->pPars->fDelayOpt )
324  {
325  pCut->Delay = If_CutSopBalanceEval( p, pCut, NULL );
326 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
327 // pCut->Delay += 1;
328  }
329  else if ( p->pPars->fDsdBalance )
330  {
331  pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
332 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
333 // pCut->Delay += 1;
334  }
335  else if ( p->pPars->fUserRecLib )
336  {
337  pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
338 // if ( pCut->Delay >= pObj->Level && pCut->nLeaves > 2 )
339 // pCut->Delay += 1;
340  }
341  else if ( p->pPars->fDelayOptLut )
342  pCut->Delay = If_CutLutBalanceEval( p, pCut );
343  else if( p->pPars->nGateSize > 0 )
344  pCut->Delay = If_CutDelaySop( p, pCut );
345  else
346  pCut->Delay = If_CutDelay( p, pObj, pCut );
347  if ( pCut->Delay == -1 )
348  continue;
349  if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
350  continue;
351  // compute area of the cut (this area may depend on the application specific cost)
352  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
353  if ( p->pPars->fEdge )
354  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
355  if ( p->pPars->fPower )
356  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
357 // pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
358  // insert the cut into storage
359  If_CutSort( p, pCutSet, pCut );
360 // If_CutTraverse( p, pObj, pCut );
361  }
362  assert( pCutSet->nCuts > 0 );
363 // If_CutVerifyCuts( pCutSet, !p->pPars->fUseTtPerm );
364 
365  // update the best cut
366  if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
367  {
368  If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
369  if(p->pPars->fUserRecLib)
370  assert(If_ObjCutBest(pObj)->Cost < IF_COST_MAX && If_ObjCutBest(pObj)->Delay < ABC_INFINITY);
371  }
372  // add the trivial cut to the set
373  if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
374  {
375  If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
376  assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
377  }
378 // if ( If_ObjCutBest(pObj)->nLeaves == 0 )
379 // p->nBestCutSmall[0]++;
380 // else if ( If_ObjCutBest(pObj)->nLeaves == 1 )
381 // p->nBestCutSmall[1]++;
382 
383  // ref the selected cut
384  if ( Mode && pObj->nRefs > 0 )
385  If_CutAreaRef( p, If_ObjCutBest(pObj) );
386  if ( If_ObjCutBest(pObj)->fUseless )
387  Abc_Print( 1, "The best cut is useless.\n" );
388  // call the user specified function for each cut
389  if ( p->pPars->pFuncUser )
390  If_ObjForEachCut( pObj, pCut, i )
391  p->pPars->pFuncUser( p, pObj, pCut );
392  // free the cuts
393  If_ManDerefNodeCutSet( p, pObj );
394 }
If_Obj_t * pFanin0
Definition: if.h:321
If_DsdMan_t * pIfDsdMan
Definition: if.h:243
int If_DsdManCheckDec(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:185
If_Set_t * pCutSet
Definition: if.h:332
unsigned nLeaves
Definition: if.h:289
int Id
Definition: if.h:316
float If_CutPowerFlow(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:979
int If_DsdManCompute(If_DsdMan_t *p, word *pTruth, int nLeaves, unsigned char *pPerm, char *pLutStruct)
Definition: ifDsd.c:2032
int If_CutMerge(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition: ifCut.c:364
unsigned nLimit
Definition: if.h:288
Vec_Str_t * vTtVars[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:248
int nLutSize
Definition: if.h:103
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float Edge
Definition: if.h:278
float If_CutAreaFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:919
Vec_Int_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:249
int If_CluCheckDecOut(word t, int nVars)
Definition: ifDec16.c:1840
#define IF_BIG_CHAR
Definition: if.h:60
static int If_ObjIsAnd(If_Obj_t *pObj)
Definition: if.h:377
Definition: if.h:275
float Required
Definition: if.h:325
int fDelayOptLut
Definition: if.h:122
int fVerbose
Definition: if.h:140
int fSkipCutFilter
Definition: if.h:144
int nCutsCountAll
Definition: if.h:240
static void If_CutCopy(If_Man_t *p, If_Cut_t *pDst, If_Cut_t *pSrc)
Definition: if.h:398
char * pLutStruct
Definition: if.h:141
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
int nCutsMerged
Definition: if.h:202
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:247
int nCutsTotal
Definition: if.h:237
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
int(* pFuncCost)(If_Man_t *, If_Cut_t *)
Definition: if.h:163
static int Abc_TtProcessBiDec(word *pTruth, int nVars, int nSuppLim)
Definition: utilTruth.h:2431
static int If_WordCountOnes(unsigned uWord)
FUNCTION DEFINITIONS ///.
Definition: ifMap.c:48
unsigned fUser
Definition: if.h:286
float If_CutEdgeDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1187
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int(* pFuncUser)(If_Man_t *, If_Obj_t *, If_Cut_t *)
Definition: if.h:164
ABC_NAMESPACE_IMPL_START void If_ManCacheRecord(If_Man_t *p, int iDsd0, int iDsd1, int nShared, int iDsd)
DECLARATIONS ///.
Definition: ifCache.c:45
int nRefs
Definition: if.h:318
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
int fUseCofVars
Definition: if.h:135
int fEnableCheck75u
Definition: if.h:132
#define If_ObjForEachCut(pObj, pCut, i)
Definition: if.h:471
int nCuts5a
Definition: if.h:242
int nCuts5
Definition: if.h:242
int nGateSize
Definition: if.h:107
unsigned Cost
Definition: if.h:284
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static word * If_CutTruthW(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:421
If_Set_t * If_ManSetupNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:579
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
int fEnableCheck75
Definition: if.h:131
int fEdge
Definition: if.h:118
int nCutsUseless[32]
Definition: if.h:238
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
int If_CutDelayRecCost3(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj)
Definition: abcRec3.c:1004
float Power
Definition: if.h:279
int fDsdBalance
Definition: if.h:123
int fTruth
Definition: if.h:146
static word * If_CutTruthWR(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:419
Definition: if.h:180
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition: ifMan.c:499
float If_CutAreaDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1086
if(last==0)
Definition: sparse_int.h:34
unsigned fSkipCut
Definition: if.h:314
int nCutsUselessAll
Definition: if.h:241
static unsigned * If_CutTruth(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:422
int If_CluCheckDecInAny(word t, int nVars)
Definition: ifDec16.c:1767
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
If_Obj_t * pFanin1
Definition: if.h:322
int If_CutMergeOrdered(If_Man_t *p, If_Cut_t *pCut0, If_Cut_t *pCut1, If_Cut_t *pCut)
Definition: ifCut.c:290
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int fUseAndVars
Definition: if.h:136
int If_CutSopBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDelay.c:248
float fEpsilon
Definition: if.h:195
int If_CutComputeTruth(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition: ifTruth.c:98
int If_DsdManSuppSize(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:181
abctime timeCache[6]
Definition: if.h:257
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
int fUseDsd
Definition: if.h:133
static int If_CutDsdLit(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:424
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
If_Par_t * pPars
Definition: if.h:184
#define IF_COST_MAX
Definition: if.h:58
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]
Definition: if.h:246
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
short nCuts
Definition: if.h:297
float If_CutDelay(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
Definition: ifTime.c:91
int(* pFuncCell)(If_Man_t *, unsigned *, int, int, char *)
Definition: if.h:165
int If_CutFilter(If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
Definition: ifCut.c:146
int fUseDsdTune
Definition: if.h:134
static int Abc_TtCheckCondDep(word *pTruth, int nVars, int nSuppLim)
Definition: utilTruth.h:1055
int fUserRecLib
Definition: if.h:124
int fPower
Definition: if.h:119
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int fDelayOpt
Definition: if.h:121
Definition: if.h:294
unsigned uSign
Definition: if.h:283
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
int fUseTtPerm
Definition: if.h:137
float EstRefs
Definition: if.h:324
#define assert(ex)
Definition: util_old.h:213
int nCutsCount[32]
Definition: if.h:239
If_Cut_t ** ppCuts
Definition: if.h:299
int If_CutDsdBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
Definition: ifDsd.c:2288
unsigned fCompl
Definition: if.h:285
unsigned fSpec
Definition: if.h:312
int If_CutLutBalanceEval(If_Man_t *p, If_Cut_t *pCut)
Definition: ifDelay.c:369
ABC_INT64_T abctime
Definition: abc_global.h:278
static char * If_CutDsdPerm(If_Man_t *p, If_Cut_t *pCut)
Definition: if.h:426
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutEdgeFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:949
unsigned fCompl1
Definition: if.h:307
int If_DsdManReadMark(If_DsdMan_t *p, int iDsd)
Definition: ifDsd.c:189
unsigned fCompl0
Definition: if.h:306
int iCutFunc
Definition: if.h:281
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
float Delay
Definition: if.h:280
int If_CutComputeTruthPerm(If_Man_t *p, If_Cut_t *pCut, If_Cut_t *pCut0, If_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition: ifTruth.c:263
float If_CutPowerDerefed(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1290
int If_CutDelaySop(If_Man_t *p, If_Cut_t *pCut)
Definition: ifDelay.c:64
void If_ManDerefNodeCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:602
float Area
Definition: if.h:277
void If_ObjPerformMappingChoice ( If_Man_t p,
If_Obj_t pObj,
int  Mode,
int  fPreprocess 
)

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

Synopsis [Finds the best cut for the choice node.]

Description []

SideEffects []

SeeAlso []

Definition at line 407 of file ifMap.c.

408 {
409  If_Set_t * pCutSet;
410  If_Obj_t * pTemp;
411  If_Cut_t * pCutTemp, * pCut;
412  int i, fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib;
413  assert( pObj->pEquiv != NULL );
414 
415  // prepare
416  if ( Mode && pObj->nRefs > 0 )
417  If_CutAreaDeref( p, If_ObjCutBest(pObj) );
418 
419  // remove elementary cuts
420  for ( pTemp = pObj; pTemp; pTemp = pTemp->pEquiv )
421  pTemp->pCutSet->nCuts--;
422 
423  // update the cutset of the node
424  pCutSet = pObj->pCutSet;
425 
426  // generate cuts
427  for ( pTemp = pObj->pEquiv; pTemp; pTemp = pTemp->pEquiv )
428  {
429  if ( pTemp->pCutSet->nCuts == 0 )
430  continue;
431  // go through the cuts of this node
432  If_ObjForEachCut( pTemp, pCutTemp, i )
433  {
434  if ( pCutTemp->fUseless )
435  continue;
436  // get the next free cut
437  assert( pCutSet->nCuts <= pCutSet->nCutsMax );
438  pCut = pCutSet->ppCuts[pCutSet->nCuts];
439  // copy the cut into storage
440  If_CutCopy( p, pCut, pCutTemp );
441  // check if this cut is contained in any of the available cuts
442  if ( If_CutFilter( pCutSet, pCut, fSave0 ) )
443  continue;
444  // check if the cut satisfies the required times
445 // assert( pCut->Delay == If_CutDelay( p, pTemp, pCut ) );
446  if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
447  continue;
448  // set the phase attribute
449  pCut->fCompl = pObj->fPhase ^ pTemp->fPhase;
450  // compute area of the cut (this area may depend on the application specific cost)
451  pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
452  if ( p->pPars->fEdge )
453  pCut->Edge = (Mode == 2)? If_CutEdgeDerefed( p, pCut ) : If_CutEdgeFlow( p, pCut );
454  if ( p->pPars->fPower )
455  pCut->Power = (Mode == 2)? If_CutPowerDerefed( p, pCut, pObj ) : If_CutPowerFlow( p, pCut, pObj );
456 // pCut->AveRefs = (Mode == 0)? (float)0.0 : If_CutAverageRefs( p, pCut );
457  // insert the cut into storage
458  If_CutSort( p, pCutSet, pCut );
459  }
460  }
461  assert( pCutSet->nCuts > 0 );
462 
463  // update the best cut
464  if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
465  If_CutCopy( p, If_ObjCutBest(pObj), pCutSet->ppCuts[0] );
466  // add the trivial cut to the set
467  if ( !pObj->fSkipCut && If_ObjCutBest(pObj)->nLeaves > 1 )
468  {
469  If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
470  assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
471  }
472 
473  // ref the selected cut
474  if ( Mode && pObj->nRefs > 0 )
475  If_CutAreaRef( p, If_ObjCutBest(pObj) );
476  // free the cuts
477  If_ManDerefChoiceCutSet( p, pObj );
478 }
If_Set_t * pCutSet
Definition: if.h:332
int Id
Definition: if.h:316
float If_CutPowerFlow(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:979
float If_CutAreaDeref(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1032
float Edge
Definition: if.h:278
float If_CutAreaFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:919
Definition: if.h:303
Definition: if.h:275
float Required
Definition: if.h:325
int fDelayOptLut
Definition: if.h:122
static void If_CutCopy(If_Man_t *p, If_Cut_t *pDst, If_Cut_t *pSrc)
Definition: if.h:398
short nCutsMax
Definition: if.h:296
unsigned fUseless
Definition: if.h:287
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
float If_CutEdgeDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1187
for(p=first;p->value< newval;p=p->next)
int nRefs
Definition: if.h:318
#define If_ObjForEachCut(pObj, pCut, i)
Definition: if.h:471
int fEdge
Definition: if.h:118
float Power
Definition: if.h:279
int fDsdBalance
Definition: if.h:123
void If_ManSetupCutTriv(If_Man_t *p, If_Cut_t *pCut, int ObjId)
Definition: ifMan.c:499
float If_CutAreaDerefed(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1086
unsigned fSkipCut
Definition: if.h:314
If_Obj_t * pEquiv
Definition: if.h:323
float fEpsilon
Definition: if.h:195
If_Par_t * pPars
Definition: if.h:184
short nCuts
Definition: if.h:297
int If_CutFilter(If_Set_t *pCutSet, If_Cut_t *pCut, int fSaveCut0)
Definition: ifCut.c:146
int fUserRecLib
Definition: if.h:124
int fPower
Definition: if.h:119
int fDelayOpt
Definition: if.h:121
Definition: if.h:294
#define assert(ex)
Definition: util_old.h:213
If_Cut_t ** ppCuts
Definition: if.h:299
unsigned fCompl
Definition: if.h:285
float If_CutAreaRef(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:1059
float If_CutEdgeFlow(If_Man_t *p, If_Cut_t *pCut)
Definition: ifCut.c:949
unsigned fPhase
Definition: if.h:308
void If_CutSort(If_Man_t *p, If_Set_t *pCutSet, If_Cut_t *pCut)
Definition: ifCut.c:738
float Delay
Definition: if.h:280
float If_CutPowerDerefed(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pRoot)
Definition: ifCut.c:1290
void If_ManDerefChoiceCutSet(If_Man_t *p, If_Obj_t *pObj)
Definition: ifMan.c:645
float Area
Definition: if.h:277
void If_ObjPrint ( If_Obj_t pObj)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 604 of file ifUtil.c.

605 {
606  if ( pObj == NULL )
607  {
608  printf( "Object is NULL." );
609  return;
610  }
611  printf( "Obj %4d : ", If_ObjId(pObj) );
612  if ( If_ObjIsConst1(pObj) )
613  printf( "constant 1" );
614  else if ( If_ObjIsCi(pObj) )
615  printf( "PI" );
616  else if ( If_ObjIsCo(pObj) )
617  printf( "PO( %4d%s )", If_ObjId(If_ObjFanin0(pObj)), (If_ObjFaninC0(pObj)? "\'" : " ") );
618  else
619  printf( "AND( %4d%s, %4d%s )",
620  If_ObjId(If_ObjFanin0(pObj)), (If_ObjFaninC0(pObj)? "\'" : " "),
621  If_ObjId(If_ObjFanin1(pObj)), (If_ObjFaninC1(pObj)? "\'" : " ") );
622  printf( " (refs = %3d)", pObj->nVisitsCopy );
623  printf( "\n" );
624 }
static int If_ObjId(If_Obj_t *pObj)
Definition: if.h:379
static int If_ObjIsCo(If_Obj_t *pObj)
Definition: if.h:374
static int If_ObjFaninC0(If_Obj_t *pObj)
Definition: if.h:382
static If_Obj_t * If_ObjFanin0(If_Obj_t *pObj)
Definition: if.h:380
static int If_ObjIsCi(If_Obj_t *pObj)
Definition: if.h:373
static int If_ObjFaninC1(If_Obj_t *pObj)
Definition: if.h:383
static If_Obj_t * If_ObjFanin1(If_Obj_t *pObj)
Definition: if.h:381
int nVisitsCopy
Definition: if.h:320
static int If_ObjIsConst1(If_Obj_t *pObj)
Definition: if.h:372
static void If_ObjSetArrTime ( If_Obj_t pObj,
float  ArrTime 
)
inlinestatic

Definition at line 406 of file if.h.

406 { If_ObjCutBest(pObj)->Delay = ArrTime; }
static If_Cut_t * If_ObjCutBest(If_Obj_t *pObj)
Definition: if.h:401
float Delay
Definition: if.h:280
static void If_ObjSetChoice ( If_Obj_t pObj,
If_Obj_t pEqu 
)
inlinestatic

Definition at line 388 of file if.h.

388 { pObj->pEquiv = pEqu; }
If_Obj_t * pEquiv
Definition: if.h:323
static void If_ObjSetCopy ( If_Obj_t pObj,
void *  pCopy 
)
inlinestatic

Definition at line 387 of file if.h.

387 { pObj->pCopy = pCopy; }
void * pCopy
Definition: if.h:328
static void If_ObjSetLevel ( If_Obj_t pObj,
int  Level 
)
inlinestatic

Definition at line 386 of file if.h.

386 { pObj->Level = Level; }
unsigned Level
Definition: if.h:315
static void If_ObjSetLValue ( If_Obj_t pObj,
float  LValue 
)
inlinestatic

Definition at line 409 of file if.h.

409 { pObj->LValue = LValue; }
float LValue
Definition: if.h:326
static If_Obj_t* If_Regular ( If_Obj_t p)
inlinestatic

Definition at line 355 of file if.h.

355 { return (If_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
Definition: if.h:303
int Ifn_NtkInputNum ( Ifn_Ntk_t p)

Definition at line 167 of file ifTune.c.

168 {
169  return p->nInps;
170 }
int nInps
Definition: ifTune.c:72
int Ifn_NtkLutSizeMax ( Ifn_Ntk_t p)

Definition at line 159 of file ifTune.c.

160 {
161  int i, LutSize = 0;
162  for ( i = p->nInps; i < p->nObjs; i++ )
163  if ( p->Nodes[i].Type == IFN_DSD_PRIME )
164  LutSize = Abc_MaxInt( LutSize, (int)p->Nodes[i].nFanins );
165  return LutSize;
166 }
unsigned nFanins
Definition: ifTune.c:64
Ifn_Obj_t Nodes[2 *IFN_INS]
Definition: ifTune.c:74
int nInps
Definition: ifTune.c:72
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
unsigned Type
Definition: ifTune.c:63
int Ifn_NtkMatch ( Ifn_Ntk_t p,
word pTruth,
int  nVars,
int  nConfls,
int  fVerbose,
int  fVeryVerbose,
word pPerm 
)

Definition at line 1207 of file ifTune.c.

1208 {
1209  word * pTruth1;
1210  int RetValue = 0;
1211  int nIterMax = (1<<nVars);
1212  int i, v, status, iMint = 0;
1213  abctime clk = Abc_Clock();
1214 // abctime clkTru = 0, clkSat = 0, clk2;
1215  sat_solver * pSat = sat_solver_new();
1216  Ifn_Prepare( p, pTruth, nVars );
1217  sat_solver_setnvars( pSat, p->nPars );
1218  Ifn_NtkAddConstraints( p, pSat );
1219  if ( fVeryVerbose )
1220  Ifn_NtkMatchPrintStatus( pSat, 0, l_True, -1, -1, Abc_Clock() - clk );
1221  if ( pPerm ) *pPerm = 0;
1222  for ( i = 0; i < nIterMax; i++ )
1223  {
1224  // get variable assignment
1225  for ( v = 0; v < p->nObjs; v++ )
1226  p->Values[v] = v < p->nVars ? (iMint >> v) & 1 : -1;
1227  p->Values[p->nObjs-1] = Abc_TtGetBit( pTruth, iMint );
1228  // derive clauses
1229  if ( !Ifn_NtkAddClauses( p, p->Values, pSat ) )
1230  break;
1231  // find assignment of parameters
1232 // clk2 = Abc_Clock();
1233  status = sat_solver_solve( pSat, NULL, NULL, nConfls, 0, 0, 0 );
1234 // clkSat += Abc_Clock() - clk2;
1235  if ( fVeryVerbose )
1236  Ifn_NtkMatchPrintStatus( pSat, i+1, status, iMint, p->Values[p->nObjs-1], Abc_Clock() - clk );
1237  if ( status != l_True )
1238  break;
1239  // collect assignment
1240  for ( v = p->nObjs; v < p->nPars; v++ )
1241  p->Values[v] = sat_solver_var_value(pSat, v);
1242  // find truth table
1243 // clk2 = Abc_Clock();
1244  pTruth1 = Ifn_NtkDeriveTruth( p, p->Values );
1245 // clkTru += Abc_Clock() - clk2;
1246  Abc_TtXor( pTruth1, pTruth1, p->pTruth, p->nWords, 0 );
1247  // find mismatch if present
1248  iMint = Abc_TtFindFirstBit( pTruth1, p->nVars );
1249  if ( iMint == -1 )
1250  {
1251  if ( pPerm )
1252  *pPerm = Ifn_NtkMatchCollectPerm( p, pSat );
1253 /*
1254  if ( pPerm )
1255  {
1256  int RetValue = Ifn_ManSatFindCofigBitsTest( p, pTruth, nVars, *pPerm );
1257  Ifn_NtkMatchPrintPerm( *pPerm, p->nInps );
1258  if ( RetValue == 0 )
1259  printf( "Verification failed.\n" );
1260  }
1261 */
1262  RetValue = 1;
1263  break;
1264  }
1265  }
1266  assert( i < nIterMax );
1267  if ( fVerbose )
1268  {
1269  printf( "%s Iter =%4d. Confl = %6d. ", RetValue ? "yes":"no ", i, sat_solver_nconflicts(pSat) );
1270  if ( RetValue )
1271  Ifn_NtkMatchPrintConfig( p, pSat );
1272  printf( "\n" );
1273  }
1274  sat_solver_delete( pSat );
1275 // Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1276 // Abc_PrintTime( 1, "Sat", clkSat );
1277 // Abc_PrintTime( 1, "Tru", clkTru );
1278  return RetValue;
1279 }
word * pTruth
Definition: ifTune.c:84
int Ifn_NtkAddClauses(Ifn_Ntk_t *p, int *pValues, sat_solver *pSat)
Definition: ifTune.c:1009
int Ifn_Prepare(Ifn_Ntk_t *p, word *pTruth, int nVars)
FUNCTION DEFINITIONS ///.
Definition: ifTune.c:115
void Ifn_NtkMatchPrintStatus(sat_solver *p, int Iter, int status, int iMint, int Value, abctime clk)
Definition: ifTune.c:1154
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
word Ifn_NtkMatchCollectPerm(Ifn_Ntk_t *p, sat_solver *pSat)
Definition: ifTune.c:1185
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static int Abc_TtFindFirstBit(word *pIn, int nVars)
Definition: utilTruth.h:1516
int sat_solver_nconflicts(sat_solver *s)
Definition: satSolver.c:1908
void Ifn_NtkAddConstraints(Ifn_Ntk_t *p, sat_solver *pSat)
Definition: ifTune.c:952
#define l_True
Definition: SolverTypes.h:84
int nVars
Definition: ifTune.c:79
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_TtGetBit(word *p, int i)
MACRO DEFINITIONS ///.
Definition: utilTruth.h:149
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
int nObjs
Definition: ifTune.c:73
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int nWords
Definition: ifTune.c:80
int Values[IFN_PAR]
Definition: ifTune.c:86
static int pPerm[13719]
Definition: rwrTemp.c:32
word * Ifn_NtkDeriveTruth(Ifn_Ntk_t *p, int *pValues)
Definition: ifTune.c:805
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
void Ifn_NtkMatchPrintConfig(Ifn_Ntk_t *p, sat_solver *pSat)
Definition: ifTune.c:1170
#define assert(ex)
Definition: util_old.h:213
int nPars
Definition: ifTune.c:83
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Abc_TtXor(word *pOut, word *pIn1, word *pIn2, int nWords, int fCompl)
Definition: utilTruth.h:253
Ifn_Ntk_t* Ifn_NtkParse ( char *  pStr)

Definition at line 439 of file ifTune.c.

440 {
441  Ifn_Ntk_t * p = ABC_CALLOC( Ifn_Ntk_t, 1 );
442  if ( Ifn_ManStrType2(pStr) )
443  {
444  if ( !Ifn_NtkParseInt2( pStr, p ) )
445  {
446  ABC_FREE( p );
447  return NULL;
448  }
449  }
450  else
451  {
452  if ( !Ifn_NtkParseInt( pStr, p ) )
453  {
454  ABC_FREE( p );
455  return NULL;
456  }
457  }
458  Ifn_NtkParseConstraints( pStr, p );
459  Abc_TtElemInit2( p->pTtElems, p->nInps );
460 // printf( "Finished parsing: " ); Ifn_NtkPrint(p);
461  return p;
462 }
int Ifn_NtkParseInt(char *pStr, Ifn_Ntk_t *p)
Definition: ifTune.c:285
static Llb_Mgr_t * p
Definition: llb3Image.c:950
word pTtElems[IFN_INS *IFN_WRD]
Definition: ifTune.c:87
int nInps
Definition: ifTune.c:72
int Ifn_ManStrType2(char *pStr)
Definition: ifTune.c:316
void Ifn_NtkParseConstraints(char *pStr, Ifn_Ntk_t *p)
Definition: ifTune.c:423
int Ifn_NtkParseInt2(char *pStr, Ifn_Ntk_t *p)
Definition: ifTune.c:378
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Abc_TtElemInit2(word *pTtElems, int nVars)
Definition: utilTruth.h:344
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void Ifn_NtkPrint ( Ifn_Ntk_t p)

Definition at line 141 of file ifTune.c.

142 {
143  int i, k;
144  if ( p == NULL )
145  printf( "String is empty.\n" );
146  if ( p == NULL )
147  return;
148  for ( i = p->nInps; i < p->nObjs; i++ )
149  {
150  printf( "%c=", 'a'+i );
151  printf( "%c", Ifn_Symbs[p->Nodes[i].Type][0] );
152  for ( k = 0; k < (int)p->Nodes[i].nFanins; k++ )
153  printf( "%c", 'a'+p->Nodes[i].Fanins[k] );
154  printf( "%c", Ifn_Symbs[p->Nodes[i].Type][1] );
155  printf( ";" );
156  }
157  printf( "\n" );
158 }
unsigned nFanins
Definition: ifTune.c:64
int Fanins[IFN_INS]
Definition: ifTune.c:67
Ifn_Obj_t Nodes[2 *IFN_INS]
Definition: ifTune.c:74
int nInps
Definition: ifTune.c:72
static char * Ifn_Symbs[16]
Definition: ifTune.c:50
unsigned Type
Definition: ifTune.c:63