ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaMf.c File Reference
#include "gia.h"
#include "misc/vec/vecMem.h"
#include "misc/util/utilTruth.h"
#include "misc/extra/extra.h"
#include "sat/cnf/cnf.h"
#include "opt/dau/dau.h"
#include "bool/kit/kit.h"
Include dependency graph for giaMf.c:

Go to the source code of this file.

Classes

struct  Mf_Cut_t_
 
struct  Mf_Obj_t_
 
struct  Mf_Man_t_
 

Macros

#define MF_LEAF_MAX   10
 DECLARATIONS ///.
 
#define MF_CUT_MAX   16
 
#define MF_LOG_PAGE   12
 
#define MF_NO_LEAF   31
 
#define MF_TT_WORDS   ((MF_LEAF_MAX > 6) ? 1 << (MF_LEAF_MAX-6) : 1)
 
#define MF_NO_FUNC   134217727
 
#define MF_EPSILON   0.005
 
#define Mf_SetForEachCut(pList, pCut, i)
 
#define Mf_ObjForEachCut(pCuts, i, nCuts)
 

Typedefs

typedef struct Mf_Cut_t_ Mf_Cut_t
 
typedef struct Mf_Obj_t_ Mf_Obj_t
 
typedef struct Mf_Man_t_ Mf_Man_t
 

Functions

int Kit_TruthToGia (Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
 DECLARATIONS ///.
 
int Mf_ManTruthCanonicize (word *t, int nVars)
 
void Mf_ManTruthQuit ()
 
Vec_Wrd_tMf_ManTruthCollect (int Limit)
 
int Mf_ManTruthCount ()
 
void Mf_ManProfileTruths (Mf_Man_t *p)
 
Vec_Int_tMf_ManDeriveCnfs (Mf_Man_t *p, int *pnVars, int *pnClas, int *pnLits)
 
Cnf_Dat_tMf_ManDeriveCnf (Mf_Man_t *p, int fCnfObjIds, int fAddOrCla)
 
void Mf_ObjMergeOrder (Mf_Man_t *p, int iObj)
 
void Mf_ManSetFlowRefs (Gia_Man_t *p, Vec_Int_t *vRefs)
 
int Mf_ManSetMapRefs (Mf_Man_t *p)
 
Gia_Man_tMf_ManDeriveMapping (Mf_Man_t *p)
 
Gia_Man_tMf_ManDeriveMappingCoarse (Mf_Man_t *p)
 
Gia_Man_tMf_ManDeriveMappingGia (Mf_Man_t *p)
 
Mf_Man_tMf_ManAlloc (Gia_Man_t *pGia, Jf_Par_t *pPars)
 
void Mf_ManFree (Mf_Man_t *p)
 
void Mf_ManSetDefaultPars (Jf_Par_t *pPars)
 
void Mf_ManPrintStats (Mf_Man_t *p, char *pTitle)
 
void Mf_ManPrintInit (Mf_Man_t *p)
 
void Mf_ManPrintQuit (Mf_Man_t *p, Gia_Man_t *pNew)
 
void Mf_ManComputeCuts (Mf_Man_t *p)
 
int Mf_CutRef_rec (Mf_Man_t *p, int *pCut)
 
int Mf_CutDeref_rec (Mf_Man_t *p, int *pCut)
 
int Mf_CutRef2_rec (Mf_Man_t *p, int *pCut, Vec_Int_t *vTemp, int Limit)
 
int Mf_CutDeref2_rec (Mf_Man_t *p, int *pCut, Vec_Int_t *vTemp, int Limit)
 
int Mf_ManMappingFromMapping (Mf_Man_t *p)
 
void Mf_ManPrintFanoutProfile (Mf_Man_t *p, Vec_Int_t *vFanCounts)
 
int Mf_ManPrintMfccStats (Mf_Man_t *p, int iObj)
 
void Mf_ManOptimizationOne (Mf_Man_t *p, int iObj)
 
void Mf_ManOptimization (Mf_Man_t *p)
 
void Mf_ManComputeMapping (Mf_Man_t *p)
 
Gia_Man_tMf_ManPerformMapping (Gia_Man_t *pGia, Jf_Par_t *pPars)
 
void * Mf_ManGenerateCnf (Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
 
void Mf_ManDumpCnf (Gia_Man_t *p, char *pFileName, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose)
 

Macro Definition Documentation

◆ MF_CUT_MAX

#define MF_CUT_MAX   16

Definition at line 36 of file giaMf.c.

◆ MF_EPSILON

#define MF_EPSILON   0.005

Definition at line 41 of file giaMf.c.

◆ MF_LEAF_MAX

#define MF_LEAF_MAX   10

DECLARATIONS ///.

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

FileName [giaMf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Cut computation.]

Author [Alan Mishchenko]`

Affiliation [UC Berkeley]

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

Revision [

Id
giaMf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 35 of file giaMf.c.

◆ MF_LOG_PAGE

#define MF_LOG_PAGE   12

Definition at line 37 of file giaMf.c.

◆ MF_NO_FUNC

#define MF_NO_FUNC   134217727

Definition at line 40 of file giaMf.c.

◆ MF_NO_LEAF

#define MF_NO_LEAF   31

Definition at line 38 of file giaMf.c.

◆ Mf_ObjForEachCut

#define Mf_ObjForEachCut ( pCuts,
i,
nCuts )
Value:
for ( i = 0, i < nCuts; i++ )

Definition at line 100 of file giaMf.c.

◆ Mf_SetForEachCut

#define Mf_SetForEachCut ( pList,
pCut,
i )
Value:
for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Mf_CutSize(pCut) + 1 )

Definition at line 99 of file giaMf.c.

◆ MF_TT_WORDS

#define MF_TT_WORDS   ((MF_LEAF_MAX > 6) ? 1 << (MF_LEAF_MAX-6) : 1)

Definition at line 39 of file giaMf.c.

Typedef Documentation

◆ Mf_Cut_t

typedef struct Mf_Cut_t_ Mf_Cut_t

Definition at line 43 of file giaMf.c.

◆ Mf_Man_t

typedef struct Mf_Man_t_ Mf_Man_t

Definition at line 62 of file giaMf.c.

◆ Mf_Obj_t

typedef struct Mf_Obj_t_ Mf_Obj_t

Definition at line 53 of file giaMf.c.

Function Documentation

◆ Kit_TruthToGia()

int Kit_TruthToGia ( Gia_Man_t * pMan,
unsigned * pTruth,
int nVars,
Vec_Int_t * vMemory,
Vec_Int_t * vLeaves,
int fHash )
extern

DECLARATIONS ///.

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

FileName [giaMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Manipulation of mapping associated with the AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
giaMap.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 80 of file kitHop.c.

81{
82 int iLit;
83 Kit_Graph_t * pGraph;
84 // transform truth table into the decomposition tree
85 if ( vMemory == NULL )
86 {
87 vMemory = Vec_IntAlloc( 0 );
88 pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
89 Vec_IntFree( vMemory );
90 }
91 else
92 pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
93 if ( pGraph == NULL )
94 {
95 printf( "Kit_TruthToGia(): Converting truth table to AIG has failed for function:\n" );
96 Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
97 }
98 // derive the AIG for the decomposition tree
99 iLit = Kit_GraphToGia( pMan, pGraph, vLeaves, fHash );
100 Kit_GraphFree( pGraph );
101 return iLit;
102}
int Kit_GraphToGia(Gia_Man_t *pMan, Kit_Graph_t *pGraph, Vec_Int_t *vLeaves, int fHash)
Definition kitHop.c:70
struct Kit_Graph_t_ Kit_Graph_t
Definition kit.h:88
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition kitGraph.c:132
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition kitGraph.c:356
Here is the caller graph for this function:

◆ Mf_CutDeref2_rec()

int Mf_CutDeref2_rec ( Mf_Man_t * p,
int * pCut,
Vec_Int_t * vTemp,
int Limit )

Definition at line 1600 of file giaMf.c.

1601{
1602 int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1603 if ( Limit == 0 ) return Count;
1604 for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1605 {
1606 Vec_IntPush( vTemp, pCut[i] );
1607 if ( !Mf_ObjMapRefDec(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
1608 Count += Mf_CutDeref2_rec( p, Mf_ObjCutBest(p, pCut[i]), vTemp, Limit-1 );
1609 }
1610 return Count;
1611}
Cube * p
Definition exorList.c:222
int Mf_CutDeref2_rec(Mf_Man_t *p, int *pCut, Vec_Int_t *vTemp, int Limit)
Definition giaMf.c:1600
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_CutDeref_rec()

int Mf_CutDeref_rec ( Mf_Man_t * p,
int * pCut )

Definition at line 1559 of file giaMf.c.

1560{
1561 int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1562 for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1563 if ( !Mf_ObjMapRefDec(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
1564 Count += Mf_CutDeref_rec( p, Mf_ObjCutBest(p, pCut[i]) );
1565 return Count;
1566}
int Mf_CutDeref_rec(Mf_Man_t *p, int *pCut)
Definition giaMf.c:1559
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_CutRef2_rec()

int Mf_CutRef2_rec ( Mf_Man_t * p,
int * pCut,
Vec_Int_t * vTemp,
int Limit )

Definition at line 1588 of file giaMf.c.

1589{
1590 int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1591 if ( Limit == 0 ) return Count;
1592 for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1593 {
1594 Vec_IntPush( vTemp, pCut[i] );
1595 if ( !Mf_ObjMapRefInc(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
1596 Count += Mf_CutRef2_rec( p, Mf_ObjCutBest(p, pCut[i]), vTemp, Limit-1 );
1597 }
1598 return Count;
1599}
int Mf_CutRef2_rec(Mf_Man_t *p, int *pCut, Vec_Int_t *vTemp, int Limit)
Definition giaMf.c:1588
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_CutRef_rec()

int Mf_CutRef_rec ( Mf_Man_t * p,
int * pCut )

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

Synopsis [Flow and area.]

Description []

SideEffects []

SeeAlso []

Definition at line 1551 of file giaMf.c.

1552{
1553 int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1554 for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1555 if ( !Mf_ObjMapRefInc(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
1556 Count += Mf_CutRef_rec( p, Mf_ObjCutBest(p, pCut[i]) );
1557 return Count;
1558}
int Mf_CutRef_rec(Mf_Man_t *p, int *pCut)
Definition giaMf.c:1551
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManAlloc()

Mf_Man_t * Mf_ManAlloc ( Gia_Man_t * pGia,
Jf_Par_t * pPars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1381 of file giaMf.c.

1382{
1383 Mf_Man_t * p;
1384 Vec_Int_t * vFlowRefs;
1385 int i, Entry;
1386 assert( pPars->nCutNum > 1 && pPars->nCutNum <= MF_CUT_MAX );
1387 assert( pPars->nLutSize > 1 && pPars->nLutSize <= MF_LEAF_MAX );
1388 ABC_FREE( pGia->pRefs );
1389 Vec_IntFreeP( &pGia->vMapping );
1390 if ( Gia_ManHasChoices(pGia) )
1391 Gia_ManSetPhase(pGia);
1392 p = ABC_CALLOC( Mf_Man_t, 1 );
1393 p->clkStart = Abc_Clock();
1394 p->pGia = pGia;
1395 p->pPars = pPars;
1396 p->vTtMem = pPars->fCutMin ? Vec_MemAllocForTT( pPars->nLutSize, 0 ) : NULL;
1397 p->pLfObjs = ABC_CALLOC( Mf_Obj_t, Gia_ManObjNum(pGia) );
1398 p->iCur = 2;
1399 Vec_PtrGrow( &p->vPages, 256 );
1400 if ( pPars->fGenCnf || pPars->fGenLit )
1401 {
1402 Vec_IntGrow( &p->vCnfSizes, 10000 );
1403 Vec_IntPush( &p->vCnfSizes, 1 );
1404 Vec_IntPush( &p->vCnfSizes, 2 );
1405 Vec_IntGrow( &p->vCnfMem, 10000 );
1406 }
1407 vFlowRefs = Vec_IntAlloc(0);
1408 Mf_ManSetFlowRefs( pGia, vFlowRefs );
1409 Vec_IntForEachEntry( vFlowRefs, Entry, i )
1410 p->pLfObjs[i].nFlowRefs = Entry;
1411 Vec_IntFree(vFlowRefs);
1412 return p;
1413}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define MF_LEAF_MAX
DECLARATIONS ///.
Definition giaMf.c:35
#define MF_CUT_MAX
Definition giaMf.c:36
void Mf_ManSetFlowRefs(Gia_Man_t *p, Vec_Int_t *vRefs)
Definition giaMf.c:1137
struct Mf_Man_t_ Mf_Man_t
Definition giaMf.c:62
struct Mf_Obj_t_ Mf_Obj_t
Definition giaMf.c:53
void Gia_ManSetPhase(Gia_Man_t *p)
Definition giaUtil.c:420
Vec_Int_t * vMapping
Definition gia.h:136
int * pRefs
Definition gia.h:118
int fGenCnf
Definition gia.h:360
int nCutNum
Definition gia.h:337
int nLutSize
Definition gia.h:336
int fCutMin
Definition gia.h:358
int fGenLit
Definition gia.h:361
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManComputeCuts()

void Mf_ManComputeCuts ( Mf_Man_t * p)

Definition at line 1531 of file giaMf.c.

1532{
1533 int i;
1534 Gia_ManForEachAndId( p->pGia, i )
1535 Mf_ObjMergeOrder( p, i );
1537 Mf_ManPrintStats( p, (char *)(p->fUseEla ? "Ela " : (p->Iter ? "Area " : "Delay")) );
1538}
int Mf_ManSetMapRefs(Mf_Man_t *p)
Definition giaMf.c:1171
void Mf_ManPrintStats(Mf_Man_t *p, char *pTitle)
Definition giaMf.c:1466
void Mf_ObjMergeOrder(Mf_Man_t *p, int iObj)
Definition giaMf.c:1026
#define Gia_ManForEachAndId(p, i)
Definition gia.h:1216
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManComputeMapping()

void Mf_ManComputeMapping ( Mf_Man_t * p)

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

Synopsis [Technology mappping.]

Description []

SideEffects []

SeeAlso []

Definition at line 1814 of file giaMf.c.

1815{
1816 int i;
1817 Gia_ManForEachAndId( p->pGia, i )
1818 Mf_ObjComputeBestCut( p, i );
1820 Mf_ManPrintStats( p, (char *)(p->fUseEla ? "Ela " : (p->Iter ? "Area " : "Delay")) );
1821}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManDeriveCnf()

Cnf_Dat_t * Mf_ManDeriveCnf ( Mf_Man_t * p,
int fCnfObjIds,
int fAddOrCla )

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

Synopsis [Derives CNF for the AIG using the mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 337 of file giaMf.c.

338{
339 Cnf_Dat_t * pCnf;
340 Gia_Obj_t * pObj;
341 int Id, DriId, nVars, nClas, nLits, iVar = 1, iCla = 0, iLit = 0;
342 Vec_Int_t * vCnfs = Mf_ManDeriveCnfs( p, &nVars, &nClas, &nLits );
343 Vec_Int_t * vCnfIds = Vec_IntStartFull( Gia_ManObjNum(p->pGia) );
344 int pFanins[16], * pCut, * pCnfIds = Vec_IntArray( vCnfIds );
345 int i, k, c, iFunc, nCubes, * pCubes, fComplLast;
346 nVars++; // zero-ID to remain unused
347 if ( fAddOrCla )
348 {
349 nClas++;
350 nLits += Gia_ManCoNum(p->pGia);
351 }
352 // create CNF IDs
353 if ( fCnfObjIds )
354 {
355 iVar += 1 + Gia_ManCiNum(p->pGia) + Gia_ManCoNum(p->pGia);
356 Gia_ManForEachCoId( p->pGia, Id, i )
357 Vec_IntWriteEntry( vCnfIds, Id, Id );
358 Gia_ManForEachAndReverseId( p->pGia, Id )
359 if ( Mf_ObjMapRefNum(p, Id) )
360 Vec_IntWriteEntry( vCnfIds, Id, Id ), iVar++;
361 Vec_IntWriteEntry( vCnfIds, 0, 0 );
362 Gia_ManForEachCiId( p->pGia, Id, i )
363 Vec_IntWriteEntry( vCnfIds, Id, Id );
364 assert( iVar == nVars );
365 }
366 else
367 {
368 Gia_ManForEachCoId( p->pGia, Id, i )
369 Vec_IntWriteEntry( vCnfIds, Id, iVar++ );
370 Gia_ManForEachAndReverseId( p->pGia, Id )
371 if ( Mf_ObjMapRefNum(p, Id) )
372 Vec_IntWriteEntry( vCnfIds, Id, iVar++ );
373 Vec_IntWriteEntry( vCnfIds, 0, iVar++ );
374 Gia_ManForEachCiId( p->pGia, Id, i )
375 Vec_IntWriteEntry( vCnfIds, Id, iVar++ );
376 assert( iVar == nVars );
377 }
378 // generate CNF
379 pCnf = ABC_CALLOC( Cnf_Dat_t, 1 );
380 pCnf->pMan = (Aig_Man_t *)p->pGia;
381 pCnf->nVars = nVars;
382 pCnf->nLiterals = nLits;
383 pCnf->nClauses = nClas;
384 pCnf->pClauses = ABC_ALLOC( int *, nClas+1 );
385 pCnf->pClauses[0] = ABC_ALLOC( int, nLits );
386 // add last clause
387 if ( fAddOrCla )
388 {
389 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
390 Gia_ManForEachCoId( p->pGia, Id, i )
391 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], 0);
392 }
393 if ( p->pPars->fCnfMapping )
394 pCnf->vMapping = Vec_IntStart( nVars );
395 // add clauses for the COs
396 Gia_ManForEachCo( p->pGia, pObj, i )
397 {
398 Id = Gia_ObjId( p->pGia, pObj );
399 DriId = Gia_ObjFaninId0( pObj, Id );
400
401 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
402 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], 0);
403 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[DriId], !Gia_ObjFaninC0(pObj));
404
405 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
406 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], 1);
407 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[DriId], Gia_ObjFaninC0(pObj));
408 // generate mapping
409 if ( pCnf->vMapping )
410 {
411 Vec_IntWriteEntry( pCnf->vMapping, pCnfIds[Id], Vec_IntSize(pCnf->vMapping) );
412 Vec_IntPush( pCnf->vMapping, 1 );
413 Vec_IntPush( pCnf->vMapping, pCnfIds[DriId] );
414 Vec_IntPush( pCnf->vMapping, Gia_ObjFaninC0(pObj) ? 0x55555555 : 0xAAAAAAAA );
415 }
416 }
417 // add clauses for the mapping
418 Gia_ManForEachAndReverseId( p->pGia, Id )
419 {
420 if ( !Mf_ObjMapRefNum(p, Id) )
421 continue;
422 pCut = Mf_ObjCutBest( p, Id );
423 iFunc = Abc_Lit2Var( Mf_CutFunc(pCut) );
424 fComplLast = Abc_LitIsCompl( Mf_CutFunc(pCut) );
425 if ( iFunc == 0 ) // constant cut
426 {
427 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
428 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[Id], !fComplLast);
429 assert( pCnf->vMapping == NULL ); // bug fix does not handle generated mapping
430 continue;
431 }
432 for ( k = 0; k < Mf_CutSize(pCut); k++ )
433 pFanins[k] = pCnfIds[pCut[k+1]];
434 pFanins[k++] = pCnfIds[Id];
435 // get clauses
436 pCubes = Vec_IntEntryP( vCnfs, Vec_IntEntry(vCnfs, iFunc) );
437 nCubes = *pCubes++;
438 for ( c = 0; c < nCubes; c++ )
439 {
440 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
441 k = Mf_CutSize(pCut);
442 assert( Mf_CubeLit(pCubes[c], k) );
443 pCnf->pClauses[0][iLit++] = Abc_Var2Lit( pFanins[k], (Mf_CubeLit(pCubes[c], k) == 2) ^ fComplLast );
444 for ( k = 0; k < Mf_CutSize(pCut); k++ )
445 if ( Mf_CubeLit(pCubes[c], k) )
446 pCnf->pClauses[0][iLit++] = Abc_Var2Lit( pFanins[k], Mf_CubeLit(pCubes[c], k) == 2 );
447 }
448 // generate mapping
449 if ( pCnf->vMapping )
450 {
451 word pTruth[4], * pTruthP = Vec_MemReadEntry(p->vTtMem, iFunc);
452 assert( p->pPars->nLutSize <= 8 );
453 Abc_TtCopy( pTruth, pTruthP, Abc_Truth6WordNum(p->pPars->nLutSize), Abc_LitIsCompl(iFunc) );
454 assert( pCnfIds[Id] >= 0 && pCnfIds[Id] < nVars );
455 Vec_IntWriteEntry( pCnf->vMapping, pCnfIds[Id], Vec_IntSize(pCnf->vMapping) );
456 Vec_IntPush( pCnf->vMapping, Mf_CutSize(pCut) );
457 for ( k = 0; k < Mf_CutSize(pCut); k++ )
458 Vec_IntPush( pCnf->vMapping, pCnfIds[pCut[k+1]] );
459 Vec_IntPush( pCnf->vMapping, (unsigned)pTruth[0] );
460 if ( Mf_CutSize(pCut) >= 6 )
461 {
462 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[0] >> 32) );
463 if ( Mf_CutSize(pCut) >= 7 )
464 {
465 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[1]) );
466 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[1] >> 32) );
467 }
468 if ( Mf_CutSize(pCut) >= 8 )
469 {
470 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[2]) );
471 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[2] >> 32) );
472 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[3]) );
473 Vec_IntPush( pCnf->vMapping, (unsigned)(pTruth[3] >> 32) );
474 }
475 }
476 }
477 }
478 // constant clause
479 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
480 pCnf->pClauses[0][iLit++] = Abc_Var2Lit(pCnfIds[0], 1);
481 assert( iCla == nClas );
482 assert( iLit == nLits );
483 // add closing pointer
484 pCnf->pClauses[iCla++] = pCnf->pClauses[0] + iLit;
485 // cleanup
486 Vec_IntFree( vCnfs );
487 // create mapping of objects into their clauses
488 if ( fCnfObjIds )
489 {
490 pCnf->pObj2Clause = ABC_FALLOC( int, Gia_ManObjNum(p->pGia) );
491 pCnf->pObj2Count = ABC_FALLOC( int, Gia_ManObjNum(p->pGia) );
492 for ( i = 0; i < pCnf->nClauses; i++ )
493 {
494 Id = Abc_Lit2Var(pCnf->pClauses[i][0]);
495 if ( pCnf->pObj2Clause[Id] == -1 )
496 {
497 pCnf->pObj2Clause[Id] = i;
498 pCnf->pObj2Count[Id] = 1;
499 }
500 else
501 {
502 assert( pCnf->pObj2Count[Id] > 0 );
503 pCnf->pObj2Count[Id]++;
504 }
505 }
506 }
507 else
508 {
509 if ( p->pGia != p->pGia0 ) // diff managers - create map for CIs/COs
510 {
511 pCnf->pVarNums = ABC_FALLOC( int, Gia_ManObjNum(p->pGia0) );
512 Gia_ManForEachCiId( p->pGia0, Id, i )
513 pCnf->pVarNums[Id] = pCnfIds[Gia_ManCiIdToId(p->pGia, i)];
514 Gia_ManForEachCoId( p->pGia0, Id, i )
515 pCnf->pVarNums[Id] = pCnfIds[Gia_ManCoIdToId(p->pGia, i)];
516/*
517 // transform polarity of the internal nodes
518 Gia_ManSetPhase( p->pGia );
519 Gia_ManForEachCo( p->pGia, pObj, i )
520 pObj->fPhase = 0;
521 for ( i = 0; i < pCnf->nLiterals; i++ )
522 if ( Gia_ManObj(p->pGia, Abc_Lit2Var(pCnf->pClauses[0][i]))->fPhase )
523 pCnf->pClauses[0][i] = Abc_LitNot( pCnf->pClauses[0][i] );
524*/
525 }
526 else
527 pCnf->pVarNums = Vec_IntReleaseArray(vCnfIds);
528 }
529 Vec_IntFree( vCnfIds );
530 return pCnf;
531}
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
Vec_Int_t * Mf_ManDeriveCnfs(Mf_Man_t *p, int *pnVars, int *pnClas, int *pnLits)
Definition giaMf.c:271
#define Gia_ManForEachCoId(p, Id, i)
Definition gia.h:1240
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachAndReverseId(p, i)
Definition gia.h:1224
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int nVars
Definition cnf.h:59
int * pObj2Count
Definition cnf.h:65
int * pObj2Clause
Definition cnf.h:64
int nLiterals
Definition cnf.h:60
int * pVarNums
Definition cnf.h:63
Vec_Int_t * vMapping
Definition cnf.h:67
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
Aig_Man_t * pMan
Definition cnf.h:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManDeriveCnfs()

Vec_Int_t * Mf_ManDeriveCnfs ( Mf_Man_t * p,
int * pnVars,
int * pnClas,
int * pnLits )

Definition at line 271 of file giaMf.c.

272{
273 int i, k, iFunc, nCubes, nLits, * pCut, pCnf[512];
274 Vec_Int_t * vLits = Vec_IntStart( Vec_IntSize(&p->vCnfSizes) );
275 Vec_Int_t * vCnfs = Vec_IntAlloc( 3 * Vec_IntSize(&p->vCnfSizes) );
276 Vec_IntFill( vCnfs, Vec_IntSize(&p->vCnfSizes), -1 );
277 assert( p->pPars->nLutSize <= 8 );
278 // constant/buffer
279 for ( iFunc = 0; iFunc < 2; iFunc++ )
280 {
281 if ( p->pPars->nLutSize <= 6 )
282 nCubes = Abc_Tt6Cnf( *Vec_MemReadEntry(p->vTtMem, iFunc), iFunc, pCnf );
283 else
284 nCubes = Abc_Tt8Cnf( Vec_MemReadEntry(p->vTtMem, iFunc), iFunc, pCnf );
285 nLits = Mf_ManCountLits( pCnf, nCubes, iFunc );
286 Vec_IntWriteEntry( vLits, iFunc, nLits );
287 Vec_IntWriteEntry( vCnfs, iFunc, Vec_IntSize(vCnfs) );
288 Vec_IntPush( vCnfs, nCubes );
289 for ( k = 0; k < nCubes; k++ )
290 Vec_IntPush( vCnfs, pCnf[k] );
291 }
292 // other functions
293 *pnVars = 1 + Gia_ManCiNum(p->pGia) + Gia_ManCoNum(p->pGia);
294 *pnClas = 1 + 2 * Gia_ManCoNum(p->pGia);
295 *pnLits = 1 + 4 * Gia_ManCoNum(p->pGia);
296 Gia_ManForEachAndId( p->pGia, i )
297 {
298 if ( !Mf_ObjMapRefNum(p, i) )
299 continue;
300 pCut = Mf_ObjCutBest( p, i );
301 //Mf_CutPrintOne( pCut );
302 iFunc = Abc_Lit2Var( Mf_CutFunc(pCut) );
303 if ( Vec_IntEntry(vCnfs, iFunc) == -1 )
304 {
305 if ( p->pPars->nLutSize <= 6 )
306 nCubes = Abc_Tt6Cnf( *Vec_MemReadEntry(p->vTtMem, iFunc), Mf_CutSize(pCut), pCnf );
307 else
308 nCubes = Abc_Tt8Cnf( Vec_MemReadEntry(p->vTtMem, iFunc), Mf_CutSize(pCut), pCnf );
309 assert( nCubes == Vec_IntEntry(&p->vCnfSizes, iFunc) );
310 nLits = Mf_ManCountLits( pCnf, nCubes, Mf_CutSize(pCut) );
311 // save CNF
312 Vec_IntWriteEntry( vLits, iFunc, nLits );
313 Vec_IntWriteEntry( vCnfs, iFunc, Vec_IntSize(vCnfs) );
314 Vec_IntPush( vCnfs, nCubes );
315 for ( k = 0; k < nCubes; k++ )
316 Vec_IntPush( vCnfs, pCnf[k] );
317 }
318 *pnVars += 1;
319 *pnClas += Vec_IntEntry(&p->vCnfSizes, iFunc);
320 *pnLits += Vec_IntEntry(vLits, iFunc);
321 }
322 Vec_IntFree( vLits );
323 return vCnfs;
324}
Here is the caller graph for this function:

◆ Mf_ManDeriveMapping()

Gia_Man_t * Mf_ManDeriveMapping ( Mf_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1229 of file giaMf.c.

1230{
1231 Vec_Int_t * vMapping;
1232 int i, k, * pCut;
1233 assert( !p->pPars->fCutMin && p->pGia->vMapping == NULL );
1234 vMapping = Vec_IntAlloc( Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
1235 Vec_IntFill( vMapping, Gia_ManObjNum(p->pGia), 0 );
1236 Gia_ManForEachAndId( p->pGia, i )
1237 {
1238 if ( !Mf_ObjMapRefNum(p, i) )
1239 continue;
1240 pCut = Mf_ObjCutBest( p, i );
1241 Vec_IntWriteEntry( vMapping, i, Vec_IntSize(vMapping) );
1242 Vec_IntPush( vMapping, Mf_CutSize(pCut) );
1243 for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1244 Vec_IntPush( vMapping, pCut[k] );
1245 Vec_IntPush( vMapping, i );
1246 }
1247 assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
1248 p->pGia->vMapping = vMapping;
1249 return p->pGia;
1250}
Here is the caller graph for this function:

◆ Mf_ManDeriveMappingCoarse()

Gia_Man_t * Mf_ManDeriveMappingCoarse ( Mf_Man_t * p)

Definition at line 1251 of file giaMf.c.

1252{
1253 Gia_Man_t * pNew, * pGia = p->pGia;
1254 Gia_Obj_t * pObj;
1255 int i, k, * pCut;
1256 assert( !p->pPars->fCutMin && pGia->pMuxes );
1257 // create new manager
1258 pNew = Gia_ManStart( Gia_ManObjNum(pGia) );
1259 pNew->pName = Abc_UtilStrsav( pGia->pName );
1260 pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
1261 // map primary inputs
1262 Gia_ManConst0(pGia)->Value = 0;
1263 Gia_ManForEachCi( pGia, pObj, i )
1264 pObj->Value = Gia_ManAppendCi( pNew );
1265 // start mapping
1266 pNew->vMapping = Vec_IntAlloc( Gia_ManObjNum(pGia) + 2*Gia_ManXorNum(pGia) + 2*Gia_ManMuxNum(pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
1267 Vec_IntFill( pNew->vMapping, Gia_ManObjNum(pGia) + 2*Gia_ManXorNum(pGia) + 2*Gia_ManMuxNum(pGia), 0 );
1268 // iterate through nodes used in the mapping
1269 Gia_ManForEachAnd( pGia, pObj, i )
1270 {
1271 if ( Gia_ObjIsMuxId(pGia, i) )
1272 pObj->Value = Gia_ManAppendMux( pNew, Gia_ObjFanin2Copy(pGia, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
1273 else if ( Gia_ObjIsXor(pObj) )
1274 pObj->Value = Gia_ManAppendXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1275 else
1276 pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1277 if ( !Mf_ObjMapRefNum(p, i) )
1278 continue;
1279 pCut = Mf_ObjCutBest( p, i );
1280 Vec_IntWriteEntry( pNew->vMapping, Abc_Lit2Var(pObj->Value), Vec_IntSize(pNew->vMapping) );
1281 Vec_IntPush( pNew->vMapping, Mf_CutSize(pCut));
1282 for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1283 Vec_IntPush( pNew->vMapping, Abc_Lit2Var(Gia_ManObj(pGia, pCut[k])->Value) );
1284 Vec_IntPush( pNew->vMapping, Abc_Lit2Var(pObj->Value) );
1285 }
1286 Gia_ManForEachCo( pGia, pObj, i )
1287 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1288 Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia) );
1289 assert( Vec_IntCap(pNew->vMapping) == 16 || Vec_IntSize(pNew->vMapping) == Vec_IntCap(pNew->vMapping) );
1290 return pNew;
1291}
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
unsigned * pMuxes
Definition gia.h:106
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManDeriveMappingGia()

Gia_Man_t * Mf_ManDeriveMappingGia ( Mf_Man_t * p)

Definition at line 1292 of file giaMf.c.

1293{
1294 Gia_Man_t * pNew;
1295 Gia_Obj_t * pObj;
1296 Vec_Int_t * vCopies = Vec_IntStartFull( Gia_ManObjNum(p->pGia) );
1297 Vec_Int_t * vMapping = Vec_IntStart( 2 * Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + 2 * (int)p->pPars->Area );
1298 Vec_Int_t * vMapping2 = Vec_IntStart( (int)p->pPars->Edge + 2 * (int)p->pPars->Area + 1000 );
1299 Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 );
1300 Vec_Int_t * vLeaves = Vec_IntAlloc( 16 );
1301 int i, k, Id, iLit, * pCut;
1302 word uTruth = 0, * pTruth = &uTruth;
1303 assert( p->pPars->fCutMin );
1304 // create new manager
1305 pNew = Gia_ManStart( Gia_ManObjNum(p->pGia) );
1306 pNew->pName = Abc_UtilStrsav( p->pGia->pName );
1307 pNew->pSpec = Abc_UtilStrsav( p->pGia->pSpec );
1308 // map primary inputs
1309 Vec_IntWriteEntry( vCopies, 0, 0 );
1310 Gia_ManForEachCiId( p->pGia, Id, i )
1311 Vec_IntWriteEntry( vCopies, Id, Gia_ManAppendCi(pNew) );
1312 // iterate through nodes used in the mapping
1313 Gia_ManForEachAnd( p->pGia, pObj, i )
1314 {
1315 if ( !Mf_ObjMapRefNum(p, i) )
1316 continue;
1317 pCut = Mf_ObjCutBest( p, i );
1318 if ( Mf_CutSize(pCut) == 0 )
1319 {
1320 assert( Abc_Lit2Var(Mf_CutFunc(pCut)) == 0 );
1321 Vec_IntWriteEntry( vCopies, i, Mf_CutFunc(pCut) );
1322 continue;
1323 }
1324 if ( Mf_CutSize(pCut) == 1 )
1325 {
1326 assert( Abc_Lit2Var(Mf_CutFunc(pCut)) == 1 );
1327 iLit = Vec_IntEntry( vCopies, pCut[1] );
1328 Vec_IntWriteEntry( vCopies, i, Abc_LitNotCond(iLit, Abc_LitIsCompl(Mf_CutFunc(pCut))) );
1329 continue;
1330 }
1331 Vec_IntClear( vLeaves );
1332 for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1333 Vec_IntPush( vLeaves, Vec_IntEntry(vCopies, pCut[k]) );
1334 pTruth = Vec_MemReadEntry( p->vTtMem, Abc_Lit2Var(Mf_CutFunc(pCut)) );
1335 iLit = Kit_TruthToGia( pNew, (unsigned *)pTruth, Vec_IntSize(vLeaves), vCover, vLeaves, 0 );
1336 Vec_IntWriteEntry( vCopies, i, Abc_LitNotCond(iLit, Abc_LitIsCompl(Mf_CutFunc(pCut))) );
1337 // create mapping
1338 Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLit), Vec_IntSize(vMapping2) );
1339 Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
1340 Vec_IntForEachEntry( vLeaves, iLit, k )
1341 Vec_IntPush( vMapping2, Abc_Lit2Var(iLit) );
1342 Vec_IntPush( vMapping2, Abc_Lit2Var(Vec_IntEntry(vCopies, i)) );
1343 }
1344 Gia_ManForEachCo( p->pGia, pObj, i )
1345 {
1346 iLit = Vec_IntEntry( vCopies, Gia_ObjFaninId0p(p->pGia, pObj) );
1347 iLit = Gia_ManAppendCo( pNew, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
1348 }
1349 Vec_IntFree( vCopies );
1350 Vec_IntFree( vCover );
1351 Vec_IntFree( vLeaves );
1352 // finish mapping
1353 if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
1354 Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
1355 else
1356 Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
1357 assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
1358 Vec_IntForEachEntry( vMapping, iLit, i )
1359 if ( iLit > 0 )
1360 Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
1361 Vec_IntAppend( vMapping, vMapping2 );
1362 Vec_IntFree( vMapping2 );
1363 // attach mapping and packing
1364 assert( pNew->vMapping == NULL );
1365 pNew->vMapping = vMapping;
1366 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p->pGia) );
1367 return pNew;
1368}
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManDumpCnf()

void Mf_ManDumpCnf ( Gia_Man_t * p,
char * pFileName,
int nLutSize,
int fCnfObjIds,
int fAddOrCla,
int fVerbose )

Definition at line 1895 of file giaMf.c.

1896{
1897 abctime clk = Abc_Clock();
1898 Cnf_Dat_t * pCnf;
1899 pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, nLutSize, fCnfObjIds, fAddOrCla, 0, fVerbose );
1900 Cnf_DataWriteIntoFile( pCnf, pFileName, 0, NULL, NULL );
1901// if ( fVerbose )
1902 {
1903 printf( "CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
1904 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1905 }
1906 Cnf_DataFree(pCnf);
1907}
ABC_INT64_T abctime
Definition abc_global.h:332
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
void Cnf_DataWriteIntoFile(Cnf_Dat_t *p, char *pFileName, int fReadable, Vec_Int_t *vForAlls, Vec_Int_t *vExists)
Definition cnfMan.c:387
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
Here is the call graph for this function:

◆ Mf_ManFree()

void Mf_ManFree ( Mf_Man_t * p)

Definition at line 1414 of file giaMf.c.

1415{
1416 assert( !p->pPars->fGenCnf || !p->pPars->fGenLit || Vec_IntSize(&p->vCnfSizes) == Vec_MemEntryNum(p->vTtMem) );
1417 if ( p->pPars->fCutMin )
1418 Vec_MemHashFree( p->vTtMem );
1419 if ( p->pPars->fCutMin )
1420 Vec_MemFree( p->vTtMem );
1421 Vec_PtrFreeData( &p->vPages );
1422 ABC_FREE( p->vCnfSizes.pArray );
1423 ABC_FREE( p->vCnfMem.pArray );
1424 ABC_FREE( p->vPages.pArray );
1425 ABC_FREE( p->vTemp.pArray );
1426 ABC_FREE( p->pLfObjs );
1427 ABC_FREE( p );
1428}
Here is the caller graph for this function:

◆ Mf_ManGenerateCnf()

void * Mf_ManGenerateCnf ( Gia_Man_t * pGia,
int nLutSize,
int fCnfObjIds,
int fAddOrCla,
int fMapping,
int fVerbose )

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

Synopsis [CNF generation]

Description []

SideEffects []

SeeAlso []

Definition at line 1877 of file giaMf.c.

1878{
1879 Gia_Man_t * pNew;
1880 Jf_Par_t Pars, * pPars = &Pars;
1881 assert( nLutSize >= 3 && nLutSize <= 8 );
1882 Mf_ManSetDefaultPars( pPars );
1883 pPars->fGenCnf = 1;
1884 pPars->fCoarsen = !fCnfObjIds;
1885 pPars->nLutSize = nLutSize;
1886 pPars->fCnfObjIds = fCnfObjIds;
1887 pPars->fAddOrCla = fAddOrCla;
1888 pPars->fCnfMapping = fMapping;
1889 pPars->fVerbose = fVerbose;
1890 pNew = Mf_ManPerformMapping( pGia, pPars );
1891 Gia_ManStopP( &pNew );
1892// Cnf_DataPrint( (Cnf_Dat_t *)pGia->pData, 1 );
1893 return pGia->pData;
1894}
Gia_Man_t * Mf_ManPerformMapping(Gia_Man_t *pGia, Jf_Par_t *pPars)
Definition giaMf.c:1822
void Mf_ManSetDefaultPars(Jf_Par_t *pPars)
Definition giaMf.c:1441
void Gia_ManStopP(Gia_Man_t **p)
Definition giaMan.c:224
struct Jf_Par_t_ Jf_Par_t
Definition gia.h:333
void * pData
Definition gia.h:198
int fCnfObjIds
Definition gia.h:362
int fCnfMapping
Definition gia.h:364
int fCoarsen
Definition gia.h:357
int fVerbose
Definition gia.h:370
int fAddOrCla
Definition gia.h:363
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManMappingFromMapping()

int Mf_ManMappingFromMapping ( Mf_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1700 of file giaMf.c.

1701{
1702 Gia_Man_t * pGia = p->pGia0;
1703 Gia_Obj_t * pObj;
1704 int i, iObj, Count = 0;
1705 Vec_Int_t * vMapping = Vec_IntAlloc( 3 * Gia_ManObjNum(pGia) );
1706 Vec_IntFill( vMapping, Gia_ManObjNum(pGia), 0 );
1707 Gia_ManForEachAnd( pGia, pObj, iObj )
1708 if ( Mf_ObjMapRefNum(p, iObj) )
1709 {
1710 int * pCut = Mf_ObjCutBest(p, iObj);
1711 Vec_IntWriteEntry( vMapping, iObj, Vec_IntSize(vMapping) );
1712 Vec_IntPush( vMapping, Mf_CutSize(pCut) );
1713 for ( i = 1; i <= Mf_CutSize(pCut); i++ )
1714 Vec_IntPush( vMapping, pCut[i] );
1715 Vec_IntPush( vMapping, iObj );
1716 Count++;
1717 }
1718 assert( pGia->vMapping == NULL );
1719 pGia->vMapping = vMapping;
1720 printf( "Mapping is %.2fx larger than AIG manager.\n", 1.0*Vec_IntSize(vMapping)/Gia_ManObjNum(pGia) );
1721 return Count;
1722}
Here is the caller graph for this function:

◆ Mf_ManOptimization()

void Mf_ManOptimization ( Mf_Man_t * p)

Definition at line 1786 of file giaMf.c.

1787{
1788 int nOutMax = 3;
1789 Gia_Man_t * pGia = p->pGia0;
1790 int i, Count, nNodes = Mf_ManMappingFromMapping( p );
1791 Gia_ManLevelNum( pGia );
1792 Gia_ManStaticMappingFanoutStart( pGia, NULL );
1794 printf( "\nIndividual logic cones for mapping with %d nodes:\n", nNodes );
1795 Vec_IntForEachEntry( pGia->vFanoutNums, Count, i )
1796 if ( Count >= 2 && Count <= nOutMax && Gia_ObjIsAnd(Gia_ManObj(pGia, i)) )
1798 printf( "\nFinished printing individual logic cones.\n" );
1800 Vec_IntFreeP( &pGia->vMapping );
1801}
void Mf_ManPrintFanoutProfile(Mf_Man_t *p, Vec_Int_t *vFanCounts)
Definition giaMf.c:1735
int Mf_ManMappingFromMapping(Mf_Man_t *p)
Definition giaMf.c:1700
void Mf_ManOptimizationOne(Mf_Man_t *p, int iObj)
Definition giaMf.c:1757
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
Definition giaFanout.c:393
void Gia_ManStaticMappingFanoutStart(Gia_Man_t *p, Vec_Int_t **pvIndex)
Definition giaFanout.c:335
int Gia_ManLevelNum(Gia_Man_t *p)
Definition giaUtil.c:546
Vec_Int_t * vFanoutNums
Definition gia.h:134
Here is the call graph for this function:

◆ Mf_ManOptimizationOne()

void Mf_ManOptimizationOne ( Mf_Man_t * p,
int iObj )

Definition at line 1757 of file giaMf.c.

1758{
1759 Gia_Man_t * pGia = p->pGia0;
1760 int * ppCuts[32], nCuts = 0;
1761 int iFanout, i, nAreaSum = 0, nAreaBest = 0;
1762 // skip pivots whose MFFC fanouts are pointed to by COs
1763 Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
1764 if ( Gia_ObjIsCo(Gia_ManObj(pGia, iFanout)) )
1765 return;
1766 // the pivot is used in the mapping as well as all of its fanouts
1767 assert( Mf_ObjMapRefNum(p, iObj) > 1 );
1768 Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
1769 assert( Mf_ObjMapRefNum(p, iFanout) > 0 );
1770 // print this pivot and its fanouts
1771 printf( "\nPivot node = %d\n", iObj );
1772 printf( "Pivot " ), Mf_ManPrintMfccStats( p, iObj );
1773 Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
1774 printf( "Node " ), nAreaSum += Mf_ManPrintMfccStats( p, iFanout );
1775 // calculate the shared MFFC
1776 Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
1777 Mf_ObjMapRefInc( p, iFanout );
1778 Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
1779 ppCuts[nCuts++] = Mf_ObjCutBest( p, iFanout );
1780 nAreaBest = Mf_CutAreaRefed2Multi( p, iObj, ppCuts, nCuts );
1781 Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
1782 Mf_ObjMapRefDec( p, iFanout );
1783 printf( "Sum of MFFC sizes = %d\n", nAreaSum );
1784 printf( "Shared MFFC size = %d\n", nAreaBest );
1785}
int Mf_ManPrintMfccStats(Mf_Man_t *p, int iObj)
Definition giaMf.c:1749
#define Gia_ObjForEachFanoutStaticId(p, Id, FanId, i)
Definition gia.h:1127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManPerformMapping()

Gia_Man_t * Mf_ManPerformMapping ( Gia_Man_t * pGia,
Jf_Par_t * pPars )

Definition at line 1822 of file giaMf.c.

1823{
1824 Mf_Man_t * p;
1825 Gia_Man_t * pNew, * pCls;
1826 if ( pPars->fGenCnf || pPars->fGenLit )
1827 pPars->fCutMin = 1;
1828 if ( Gia_ManHasChoices(pGia) )
1829 pPars->fCutMin = 1, pPars->fCoarsen = 0;
1830 pCls = pPars->fCoarsen ? Gia_ManDupMuxes(pGia, pPars->nCoarseLimit) : pGia;
1831 p = Mf_ManAlloc( pCls, pPars );
1832 p->pGia0 = pGia;
1833 if ( pPars->fVerbose && pPars->fCoarsen )
1834 {
1835 printf( "Initial " ); Gia_ManPrintMuxStats( pGia ); printf( "\n" );
1836 printf( "Derived " ); Gia_ManPrintMuxStats( pCls ); printf( "\n" );
1837 }
1838 Mf_ManPrintInit( p );
1840 for ( p->Iter = 1; p->Iter < p->pPars->nRounds; p->Iter++ )
1842 p->fUseEla = 1;
1843 for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
1845 //Mf_ManOptimization( p );
1846 if ( pPars->fVeryVerbose && pPars->fCutMin )
1847 Vec_MemDumpTruthTables( p->vTtMem, Gia_ManName(p->pGia), pPars->nLutSize );
1848 if ( pPars->fCutMin )
1849 pNew = Mf_ManDeriveMappingGia( p );
1850 else if ( pPars->fCoarsen )
1851 pNew = Mf_ManDeriveMappingCoarse( p );
1852 else
1853 pNew = Mf_ManDeriveMapping( p );
1854 if ( p->pPars->fGenCnf )
1855 pGia->pData = Mf_ManDeriveCnf( p, p->pPars->fCnfObjIds, p->pPars->fAddOrCla );
1856 //if ( p->pPars->fGenCnf || p->pPars->fGenLit )
1857 // Mf_ManProfileTruths( p );
1858 Gia_ManMappingVerify( pNew );
1859 Mf_ManPrintQuit( p, pNew );
1860 Mf_ManFree( p );
1861 if ( pCls != pGia )
1862 Gia_ManStop( pCls );
1863 return pNew;
1864}
void Mf_ManPrintQuit(Mf_Man_t *p, Gia_Man_t *pNew)
Definition giaMf.c:1497
Gia_Man_t * Mf_ManDeriveMapping(Mf_Man_t *p)
Definition giaMf.c:1229
Cnf_Dat_t * Mf_ManDeriveCnf(Mf_Man_t *p, int fCnfObjIds, int fAddOrCla)
Definition giaMf.c:337
Gia_Man_t * Mf_ManDeriveMappingCoarse(Mf_Man_t *p)
Definition giaMf.c:1251
void Mf_ManFree(Mf_Man_t *p)
Definition giaMf.c:1414
void Mf_ManComputeMapping(Mf_Man_t *p)
Definition giaMf.c:1814
void Mf_ManPrintInit(Mf_Man_t *p)
Definition giaMf.c:1481
Gia_Man_t * Mf_ManDeriveMappingGia(Mf_Man_t *p)
Definition giaMf.c:1292
void Mf_ManComputeCuts(Mf_Man_t *p)
Definition giaMf.c:1531
Mf_Man_t * Mf_ManAlloc(Gia_Man_t *pGia, Jf_Par_t *pPars)
Definition giaMf.c:1381
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
Definition giaMuxes.c:98
void Gia_ManPrintMuxStats(Gia_Man_t *p)
Definition giaMuxes.c:63
void Gia_ManMappingVerify(Gia_Man_t *p)
Definition giaIf.c:2257
int nRoundsEla
Definition gia.h:340
int fVeryVerbose
Definition gia.h:371
int nCoarseLimit
Definition gia.h:342
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManPrintFanoutProfile()

void Mf_ManPrintFanoutProfile ( Mf_Man_t * p,
Vec_Int_t * vFanCounts )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1735 of file giaMf.c.

1736{
1737 Gia_Man_t * pGia = p->pGia0;
1738 int i, Count, nMax = Vec_IntFindMax( vFanCounts );
1739 Vec_Int_t * vCounts = Vec_IntStart( nMax + 1 );
1740 Vec_IntForEachEntry( vFanCounts, Count, i )
1741 if ( Count && Gia_ObjIsAnd(Gia_ManObj(pGia, i)) )
1742 Vec_IntAddToEntry( vCounts, Count, 1 );
1743 printf( "\nFanout distribution for internal nodes:\n" );
1744 Vec_IntForEachEntry( vCounts, Count, i )
1745 if ( Count ) printf( "Fanout = %5d : Nodes = %5d.\n", i, Count );
1746 printf( "Total nodes with fanout = %d. Max fanout = %d.\n\n", Vec_IntCountPositive(vCounts), nMax );
1747 Vec_IntFree( vCounts );
1748}
Here is the caller graph for this function:

◆ Mf_ManPrintInit()

void Mf_ManPrintInit ( Mf_Man_t * p)

Definition at line 1481 of file giaMf.c.

1482{
1483 if ( !p->pPars->fVerbose )
1484 return;
1485 printf( "LutSize = %d ", p->pPars->nLutSize );
1486 printf( "CutNum = %d ", p->pPars->nCutNum );
1487 printf( "Iter = %d ", p->pPars->nRounds + p->pPars->nRoundsEla );
1488 printf( "Edge = %d ", p->pPars->fOptEdge );
1489 printf( "CutMin = %d ", p->pPars->fCutMin );
1490 printf( "Coarse = %d ", p->pPars->fCoarsen );
1491 printf( "CNF = %d ", p->pPars->fGenCnf );
1492 printf( "FFL = %d ", p->pPars->fGenLit );
1493 printf( "\n" );
1494 printf( "Computing cuts...\r" );
1495 fflush( stdout );
1496}
Here is the caller graph for this function:

◆ Mf_ManPrintMfccStats()

int Mf_ManPrintMfccStats ( Mf_Man_t * p,
int iObj )

Definition at line 1749 of file giaMf.c.

1750{
1751 Gia_Man_t * pGia = p->pGia0;
1752 int Area;
1753 printf( "%5d : Level = %5d Refs = %5d Mffc = %5d\n",
1754 iObj, Gia_ObjLevelId(pGia, iObj), Mf_ObjMapRefNum(p, iObj), (Area = Mf_CutAreaMffc(p, iObj)) );
1755 return Area;
1756}
Here is the caller graph for this function:

◆ Mf_ManPrintQuit()

void Mf_ManPrintQuit ( Mf_Man_t * p,
Gia_Man_t * pNew )

Definition at line 1497 of file giaMf.c.

1498{
1499 float MemGia = Gia_ManMemory(p->pGia) / (1<<20);
1500 float MemMan = 1.0 * sizeof(Mf_Obj_t) * Gia_ManObjNum(p->pGia) / (1<<20);
1501 float MemCuts = 1.0 * sizeof(int) * (1 << 16) * Vec_PtrSize(&p->vPages) / (1<<20);
1502 float MemTt = p->vTtMem ? Vec_MemMemory(p->vTtMem) / (1<<20) : 0;
1503 float MemMap = Vec_IntMemory(pNew->vMapping) / (1<<20);
1504 if ( p->CutCount[0] == 0 )
1505 p->CutCount[0] = 1;
1506 if ( !p->pPars->fVerbose )
1507 return;
1508 printf( "CutPair = %.0f ", p->CutCount[0] );
1509 printf( "Merge = %.0f (%.2f %%) ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
1510 printf( "Eval = %.0f (%.2f %%) ", p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
1511 printf( "Cut = %.0f (%.2f %%) ", p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
1512 printf( "\n" );
1513 printf( "Gia = %.2f MB ", MemGia );
1514 printf( "Man = %.2f MB ", MemMan );
1515 printf( "Cut = %.2f MB ", MemCuts );
1516 printf( "Map = %.2f MB ", MemMap );
1517 printf( "TT = %.2f MB ", MemTt );
1518 printf( "Total = %.2f MB", MemGia + MemMan + MemCuts + MemMap + MemTt );
1519 printf( "\n" );
1520 if ( 1 )
1521 {
1522 int i;
1523 for ( i = 0; i <= p->pPars->nLutSize; i++ )
1524 printf( "%d = %d ", i, p->nCutCounts[i] );
1525 if ( p->vTtMem )
1526 printf( "TT = %d (%.2f %%) ", Vec_MemEntryNum(p->vTtMem), 100.0 * Vec_MemEntryNum(p->vTtMem) / p->CutCount[2] );
1527 Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
1528 }
1529 fflush( stdout );
1530}
double Gia_ManMemory(Gia_Man_t *p)
Definition giaMan.c:194
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManPrintStats()

void Mf_ManPrintStats ( Mf_Man_t * p,
char * pTitle )

Definition at line 1466 of file giaMf.c.

1467{
1468 if ( !p->pPars->fVerbose )
1469 return;
1470 printf( "%s : ", pTitle );
1471 printf( "Level =%6lu ", (long)p->pPars->Delay );
1472 printf( "Area =%9lu ", (long)p->pPars->Area );
1473 printf( "Edge =%9lu ", (long)p->pPars->Edge );
1474 if ( p->pPars->fGenCnf )
1475 printf( "CNF =%9lu ", (long)p->pPars->Clause );
1476 if ( p->pPars->fGenLit )
1477 printf( "FFL =%9lu ", (long)p->pPars->Clause );
1478 Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
1479 fflush( stdout );
1480}
Here is the caller graph for this function:

◆ Mf_ManProfileTruths()

void Mf_ManProfileTruths ( Mf_Man_t * p)

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

Synopsis [Collect truth tables used by the mapper.]

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file giaMf.c.

218{
219 Vec_Int_t * vCounts;
220 int i, Entry, * pCut, Counter = 0;
221 vCounts = Vec_IntStart( Vec_IntSize(&p->vCnfSizes) );
222 Gia_ManForEachAndId( p->pGia, i )
223 {
224 if ( !Mf_ObjMapRefNum(p, i) )
225 continue;
226 pCut = Mf_ObjCutBest( p, i );
227 Vec_IntAddToEntry( vCounts, Abc_Lit2Var(Mf_CutFunc(pCut)), 1 );
228 }
229 Vec_IntForEachEntry( vCounts, Entry, i )
230 {
231 if ( Entry == 0 )
232 continue;
233 printf( "%6d : ", Counter++ );
234 printf( "%6d : ", i );
235 printf( "Occur = %4d ", Entry );
236 printf( "CNF size = %2d ", Vec_IntEntry(&p->vCnfSizes, i) );
237 Dau_DsdPrintFromTruth( Vec_MemReadEntry(p->vTtMem, i), p->pPars->nLutSize );
238 }
239 Vec_IntFree( vCounts );
240}
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition dauDsd.c:1968
Here is the call graph for this function:

◆ Mf_ManSetDefaultPars()

void Mf_ManSetDefaultPars ( Jf_Par_t * pPars)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1441 of file giaMf.c.

1442{
1443 memset( pPars, 0, sizeof(Jf_Par_t) );
1444 pPars->nLutSize = 6;
1445 pPars->nCutNum = 8;
1446 pPars->nProcNum = 0;
1447 pPars->nRounds = 2;
1448 pPars->nRoundsEla = 1;
1449 pPars->nRelaxRatio = 0;
1450 pPars->nCoarseLimit = 3;
1451 pPars->nAreaTuner = 1;
1452 pPars->nVerbLimit = 5;
1453 pPars->DelayTarget = -1;
1454 pPars->fAreaOnly = 0;
1455 pPars->fOptEdge = 1;
1456 pPars->fCoarsen = 1;
1457 pPars->fCutMin = 0;
1458 pPars->fGenCnf = 0;
1459 pPars->fGenLit = 0;
1460 pPars->fPureAig = 0;
1461 pPars->fVerbose = 0;
1462 pPars->fVeryVerbose = 0;
1463 pPars->nLutSizeMax = MF_LEAF_MAX;
1464 pPars->nCutNumMax = MF_CUT_MAX;
1465}
int nRounds
Definition gia.h:339
int nProcNum
Definition gia.h:338
int nRelaxRatio
Definition gia.h:341
int fOptEdge
Definition gia.h:354
int fAreaOnly
Definition gia.h:350
int nCutNumMax
Definition gia.h:373
int nLutSizeMax
Definition gia.h:372
int nAreaTuner
Definition gia.h:343
int fPureAig
Definition gia.h:365
int nVerbLimit
Definition gia.h:345
int DelayTarget
Definition gia.h:349
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManSetFlowRefs()

void Mf_ManSetFlowRefs ( Gia_Man_t * p,
Vec_Int_t * vRefs )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1137 of file giaMf.c.

1138{
1139 int fDiscount = 1;
1140 Gia_Obj_t * pObj, * pCtrl, * pData0, * pData1;
1141 int i, Id;
1142 Vec_IntFill( vRefs, Gia_ManObjNum(p), 0 );
1143 Gia_ManForEachAnd( p, pObj, i )
1144 {
1145 if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
1146 Vec_IntAddToEntry( vRefs, Gia_ObjFaninId0(pObj, i), 1 );
1147 if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
1148 Vec_IntAddToEntry( vRefs, Gia_ObjFaninId1(pObj, i), 1 );
1149 if ( p->pMuxes )
1150 {
1151 if ( Gia_ObjIsMuxId(p, i) && Gia_ObjIsAnd(Gia_ObjFanin2(p, pObj)) )
1152 Vec_IntAddToEntry( vRefs, Gia_ObjFaninId2(p, i), 1 );
1153 }
1154 else if ( fDiscount && Gia_ObjIsMuxType(pObj) ) // discount XOR/MUX
1155 {
1156 pCtrl = Gia_Regular(Gia_ObjRecognizeMux(pObj, &pData1, &pData0));
1157 pData0 = Gia_Regular(pData0);
1158 pData1 = Gia_Regular(pData1);
1159 if ( Gia_ObjIsAnd(pCtrl) )
1160 Vec_IntAddToEntry( vRefs, Gia_ObjId(p, pCtrl), -1 );
1161 if ( pData0 == pData1 && Gia_ObjIsAnd(pData0) )
1162 Vec_IntAddToEntry( vRefs, Gia_ObjId(p, pData0), -1 );
1163 }
1164 }
1165 Gia_ManForEachCoDriverId( p, Id, i )
1166 if ( Gia_ObjIsAnd(Gia_ManObj(p, Id)) )
1167 Vec_IntAddToEntry( vRefs, Id, 1 );
1168 for ( i = 0; i < Vec_IntSize(vRefs); i++ )
1169 Vec_IntUpdateEntry( vRefs, i, 1 );
1170}
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition giaUtil.c:1056
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition gia.h:1246
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition giaUtil.c:982
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManSetMapRefs()

int Mf_ManSetMapRefs ( Mf_Man_t * p)

Definition at line 1171 of file giaMf.c.

1172{
1173 float Coef = 1.0 / (1.0 + (p->Iter + 1) * (p->Iter + 1));
1174 int * pCut, i, k, Id;
1175 // compute delay
1176 int Delay = 0;
1177 Gia_ManForEachCoDriverId( p->pGia, Id, i )
1178 Delay = Abc_MaxInt( Delay, Mf_ManObj(p, Id)->Delay );
1179 // check delay target
1180 if ( p->pPars->DelayTarget == -1 && p->pPars->nRelaxRatio )
1181 p->pPars->DelayTarget = (int)((float)Delay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
1182 if ( p->pPars->DelayTarget != -1 )
1183 {
1184 if ( Delay < p->pPars->DelayTarget + 0.01 )
1185 Delay = p->pPars->DelayTarget;
1186 else if ( p->pPars->nRelaxRatio == 0 )
1187 Abc_Print( 0, "Relaxing user-specified delay target from %d to %d.\n", p->pPars->DelayTarget, Delay );
1188 }
1189 p->pPars->Delay = Delay;
1190 // check references
1191// Gia_ManForEachAndId( p->pGia, i )
1192// assert( Mf_ManObj(p, i)->nMapRefs == 0 );
1193 // compute area and edges
1194 if ( !p->fUseEla )
1195 Gia_ManForEachCoDriverId( p->pGia, Id, i )
1196 Mf_ObjMapRefInc( p, Id );
1197 p->pPars->Area = p->pPars->Edge = p->pPars->Clause = 0;
1198 Gia_ManForEachAndReverseId( p->pGia, i )
1199 {
1200 if ( !Mf_ObjMapRefNum(p, i) )
1201 continue;
1202 pCut = Mf_ObjCutBest( p, i );
1203 if ( !p->fUseEla )
1204 for ( k = 1; k <= Mf_CutSize(pCut); k++ )
1205 Mf_ObjMapRefInc( p, pCut[k] );
1206 p->pPars->Edge += Mf_CutSize(pCut);
1207 p->pPars->Area++;
1208 if ( p->pPars->fGenCnf || p->pPars->fGenLit )
1209 p->pPars->Clause += Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
1210 }
1211 // blend references
1212 for ( i = 0; i < Gia_ManObjNum(p->pGia); i++ )
1213 p->pLfObjs[i].nFlowRefs = Coef * p->pLfObjs[i].nFlowRefs + (1.0 - Coef) * Abc_MaxFloat(1, p->pLfObjs[i].nMapRefs);
1214// p->pLfObjs[i]. = 0.2 * p->pLfObjs[i]. + 0.8 * Abc_MaxFloat(1, p->pLfObjs[i].nMapRefs);
1215 return p->pPars->Area;
1216}
Here is the caller graph for this function:

◆ Mf_ManTruthCanonicize()

int Mf_ManTruthCanonicize ( word * t,
int nVars )

Definition at line 121 of file giaMf.c.

122{
123 word Temp, Best = *t;
124 int r, i, Config = 0;
125 for ( r = 0; r < 1; r++ )
126 {
127 if ( Best > (Temp = ~Best) )
128 Best = Temp, Config ^= (1 << nVars);
129 for ( i = 0; i < nVars; i++ )
130 if ( Best > (Temp = Abc_Tt6Flip(Best, i)) )
131 Best = Temp, Config ^= (1 << i);
132 }
133 *t = Best;
134 if ( s_vTtMem == NULL )
135 s_vTtMem = Vec_MemAllocForTT( 6, 0 );
136 Vec_MemHashInsert( s_vTtMem, t );
137 s_nCalls++;
138 return Config;
139}
Here is the caller graph for this function:

◆ Mf_ManTruthCollect()

Vec_Wrd_t * Mf_ManTruthCollect ( int Limit)

Definition at line 151 of file giaMf.c.

152{
153 extern Vec_Wrd_t * Mpm_ManGetTruthWithCnf( int Limit );
154 int * pPerm = Extra_PermSchedule( 6 );
155 int * pComp = Extra_GreyCodeSchedule( 6 );
156 Vec_Wrd_t * vTruths = Mpm_ManGetTruthWithCnf( Limit );
157 Vec_Wrd_t * vResult = Vec_WrdAlloc( 1 << 20 );
158 word uTruth, tCur, tTemp1, tTemp2;
159 int i, p, c, k;
160 Vec_WrdForEachEntry( vTruths, uTruth, k )
161 {
162 for ( i = 0; i < 2; i++ )
163 {
164 tCur = i ? ~uTruth : uTruth;
165 tTemp1 = tCur;
166 for ( p = 0; p < 720; p++ )
167 {
168 tTemp2 = tCur;
169 for ( c = 0; c < 64; c++ )
170 {
171 tCur = Abc_Tt6Flip( tCur, pComp[c] );
172 Vec_WrdPush( vResult, tCur );
173 }
174 assert( tTemp2 == tCur );
175 tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[p] );
176 }
177 assert( tTemp1 == tCur );
178 }
179 }
180 ABC_FREE( pPerm );
181 ABC_FREE( pComp );
182 printf( "Original = %d. ", Vec_WrdSize(vTruths) );
183 Vec_WrdFree( vTruths );
184 printf( "Total = %d. ", Vec_WrdSize(vResult) );
185 vTruths = Vec_WrdUniqifyHash( vResult, 1 );
186 Vec_WrdFree( vResult );
187 printf( "Unique = %d. ", Vec_WrdSize(vTruths) );
188 Vec_WrdForEachEntry( vTruths, uTruth, k )
189 {
190 Mf_ManTruthCanonicize( &uTruth, 6 );
191 Vec_WrdWriteEntry( vTruths, k, uTruth );
192 }
193 vResult = Vec_WrdUniqifyHash( vTruths, 1 );
194 Vec_WrdFree( vTruths );
195 printf( "Unique = %d. \n", Vec_WrdSize(vResult) );
196 return vResult;
197}
int * Extra_PermSchedule(int n)
int * Extra_GreyCodeSchedule(int n)
int Mf_ManTruthCanonicize(word *t, int nVars)
Definition giaMf.c:121
Vec_Wrd_t * Mpm_ManGetTruthWithCnf(int Limit)
FUNCTION DEFINITIONS ///.
Definition mpmDsd.c:644
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecWrd.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mf_ManTruthCount()

int Mf_ManTruthCount ( )

Definition at line 198 of file giaMf.c.

199{
200 Vec_Wrd_t * vTruths = Mf_ManTruthCollect( 10 );
201 int RetValue = Vec_WrdSize( vTruths );
202 Vec_WrdFree( vTruths );
203 return RetValue;
204}
Vec_Wrd_t * Mf_ManTruthCollect(int Limit)
Definition giaMf.c:151
Here is the call graph for this function:

◆ Mf_ManTruthQuit()

void Mf_ManTruthQuit ( )

Definition at line 140 of file giaMf.c.

141{
142 if ( s_vTtMem == NULL )
143 return;
144 printf( "TT = %d (%.2f %%)\n", Vec_MemEntryNum(s_vTtMem), 100.0 * Vec_MemEntryNum(s_vTtMem) / s_nCalls );
145 Vec_MemHashFree( s_vTtMem );
146 Vec_MemFree( s_vTtMem );
147 s_vTtMem = NULL;
148 s_nCalls = 0;
149}

◆ Mf_ObjMergeOrder()

void Mf_ObjMergeOrder ( Mf_Man_t * p,
int iObj )

Definition at line 1026 of file giaMf.c.

1027{
1028 Mf_Cut_t pCuts0[MF_CUT_MAX], pCuts1[MF_CUT_MAX], pCuts[MF_CUT_MAX], * pCutsR[MF_CUT_MAX];
1029 Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
1030 Mf_Obj_t * pBest = Mf_ManObj(p, iObj);
1031 int nLutSize = p->pPars->nLutSize;
1032 int nCutNum = p->pPars->nCutNum;
1033 int nCuts0 = Mf_ManPrepareCuts(pCuts0, p, Gia_ObjFaninId0(pObj, iObj), 1);
1034 int nCuts1 = Mf_ManPrepareCuts(pCuts1, p, Gia_ObjFaninId1(pObj, iObj), 1);
1035 int fComp0 = Gia_ObjFaninC0(pObj);
1036 int fComp1 = Gia_ObjFaninC1(pObj);
1037 int iSibl = Gia_ObjSibl(p->pGia, iObj);
1038 Mf_Cut_t * pCut0, * pCut1, * pCut0Lim = pCuts0 + nCuts0, * pCut1Lim = pCuts1 + nCuts1;
1039 int i, nCutsR = 0;
1040 for ( i = 0; i < nCutNum; i++ )
1041 pCutsR[i] = pCuts + i;
1042 if ( iSibl )
1043 {
1044 Mf_Cut_t pCuts2[MF_CUT_MAX];
1045 Gia_Obj_t * pObjE = Gia_ObjSiblObj(p->pGia, iObj);
1046 int fCompE = Gia_ObjPhase(pObj) ^ Gia_ObjPhase(pObjE);
1047 int nCuts2 = Mf_ManPrepareCuts(pCuts2, p, iSibl, 0);
1048 Mf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
1049 for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
1050 {
1051 *pCutsR[nCutsR] = *pCut2;
1052 if ( pCutsR[nCutsR]->iFunc >= 0 )
1053 pCutsR[nCutsR]->iFunc = Abc_LitNotCond( pCutsR[nCutsR]->iFunc, fCompE );
1054 Mf_CutParams( p, pCutsR[nCutsR], pBest->nFlowRefs );
1055 nCutsR = Mf_SetAddCut( pCutsR, nCutsR, nCutNum );
1056 }
1057 }
1058 if ( Gia_ObjIsMuxId(p->pGia, iObj) )
1059 {
1060 Mf_Cut_t pCuts2[MF_CUT_MAX];
1061 int nCuts2 = Mf_ManPrepareCuts(pCuts2, p, Gia_ObjFaninId2(p->pGia, iObj), 1);
1062 int fComp2 = Gia_ObjFaninC2(p->pGia, pObj);
1063 Mf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
1064 p->CutCount[0] += nCuts0 * nCuts1 * nCuts2;
1065 for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
1066 for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
1067 for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
1068 {
1069 if ( Mf_CutCountBits(pCut0->Sign | pCut1->Sign | pCut2->Sign) > nLutSize )
1070 continue;
1071 p->CutCount[1]++;
1072 if ( !Mf_CutMergeOrderMux(pCut0, pCut1, pCut2, pCutsR[nCutsR], nLutSize) )
1073 continue;
1074 if ( Mf_SetLastCutIsContained(pCutsR, nCutsR) )
1075 continue;
1076 p->CutCount[2]++;
1077 if ( p->pPars->fCutMin && Mf_CutComputeTruthMux(p, pCut0, pCut1, pCut2, fComp0, fComp1, fComp2, pCutsR[nCutsR]) )
1078 pCutsR[nCutsR]->Sign = Mf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
1079 Mf_CutParams( p, pCutsR[nCutsR], pBest->nFlowRefs );
1080 nCutsR = Mf_SetAddCut( pCutsR, nCutsR, nCutNum );
1081 }
1082 }
1083 else
1084 {
1085 int fIsXor = Gia_ObjIsXor(pObj);
1086 p->CutCount[0] += nCuts0 * nCuts1;
1087 for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
1088 for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
1089 {
1090 if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nLutSize && Mf_CutCountBits(pCut0->Sign | pCut1->Sign) > nLutSize )
1091 continue;
1092 p->CutCount[1]++;
1093 if ( !Mf_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nLutSize) )
1094 continue;
1095 if ( Mf_SetLastCutIsContained(pCutsR, nCutsR) )
1096 continue;
1097 p->CutCount[2]++;
1098 if ( p->pPars->fCutMin && Mf_CutComputeTruth(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
1099 pCutsR[nCutsR]->Sign = Mf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
1100 Mf_CutParams( p, pCutsR[nCutsR], pBest->nFlowRefs );
1101 nCutsR = Mf_SetAddCut( pCutsR, nCutsR, nCutNum );
1102 }
1103 }
1104 // debug printout
1105 if ( 0 )
1106// if ( iObj % 1000 == 0 )
1107// if ( iObj == 474 )
1108 {
1109 printf( "*** Obj = %d FlowRefs = %.2f MapRefs = %2d\n", iObj, pBest->nFlowRefs, pBest->nMapRefs );
1110 for ( i = 0; i < nCutsR; i++ )
1111 Mf_CutPrint( p, pCutsR[i] );
1112 printf( "\n" );
1113 }
1114 // store the cutset
1115 pBest->Flow = pCutsR[0]->Flow;
1116 pBest->Delay = pCutsR[0]->Delay;
1117 pBest->iCutSet = Mf_ManSaveCuts( p, pCutsR, nCutsR );
1118 // verify
1119 assert( nCutsR > 0 && nCutsR < nCutNum );
1120// assert( Mf_SetCheckArray(pCutsR, nCutsR) );
1121 p->nCutCounts[pCutsR[0]->nLeaves]++;
1122 p->CutCount[3] += nCutsR;
1123}
struct Mf_Cut_t_ Mf_Cut_t
Definition giaMf.c:43
unsigned nLeaves
Definition giaMf.c:50
int Delay
Definition giaMf.c:47
word Sign
Definition giaMf.c:46
unsigned iFunc
Definition giaMf.c:49
float Flow
Definition giaMf.c:48
float nFlowRefs
Definition giaMf.c:58
unsigned Delay
Definition giaMf.c:59
int iCutSet
Definition giaMf.c:56
unsigned nMapRefs
Definition giaMf.c:60
float Flow
Definition giaMf.c:57
Here is the caller graph for this function: