ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcCollapse.c File Reference
#include "base/abc/abc.h"
#include "aig/gia/gia.h"
#include "misc/vec/vecWec.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
Include dependency graph for abcCollapse.c:

Go to the source code of this file.

Macros

#define Abc_NtkSopForEachCube(pSop, nVars, pCube)
 

Functions

ABC_NAMESPACE_IMPL_START Abc_Ntk_tAbc_NtkCollapse (Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose)
 DECLARATIONS ///.
 
Vec_Wec_tGia_ManCreateCoSupps (Gia_Man_t *p, int fVerbose)
 
int Gia_ManCoLargestSupp (Gia_Man_t *p, Vec_Wec_t *vSupps)
 
Vec_Wec_tGia_ManIsoStrashReduceInt (Gia_Man_t *p, Vec_Wec_t *vSupps, int fVerbose)
 
int Abc_NtkClpGia_rec (Gia_Man_t *pNew, Abc_Obj_t *pNode)
 
Gia_Man_tAbc_NtkClpGia (Abc_Ntk_t *pNtk)
 
int Abc_NtkCollapseReduce (Vec_Str_t *vSop, Vec_Int_t *vSupp, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
 
sat_solverAbc_NtkClpDeriveSatSolver (Cnf_Dat_t *pCnf, int iCoObjId, Vec_Int_t *vSupp, Vec_Int_t *vAnds, Vec_Int_t *vMap, sat_solver **ppSat1, sat_solver **ppSat2, sat_solver **ppSat3)
 
Vec_Str_tAbc_NtkClpGiaOne (Gia_Man_t *p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t *vSupp, int fVerbose, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
 
Vec_Str_tAbc_NtkClpGiaOne2 (Cnf_Dat_t *pCnf, Gia_Man_t *p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t *vSupp, Vec_Int_t *vMap, int fVerbose, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
 
Vec_Ptr_tAbc_GiaDeriveSops (Abc_Ntk_t *pNtkNew, Gia_Man_t *p, Vec_Wec_t *vSupps, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
 
Abc_Ntk_tAbc_NtkFromSopsInt (Abc_Ntk_t *pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
 
Abc_Ntk_tAbc_NtkCollapseSat (Abc_Ntk_t *pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
 

Macro Definition Documentation

◆ Abc_NtkSopForEachCube

#define Abc_NtkSopForEachCube ( pSop,
nVars,
pCube )
Value:
for ( pCube = (pSop); *pCube; pCube += (nVars) + 3 )

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

Synopsis [Minimize SOP by removing redundant variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 608 of file abcCollapse.c.

Function Documentation

◆ Abc_GiaDeriveSops()

Vec_Ptr_t * Abc_GiaDeriveSops ( Abc_Ntk_t * pNtkNew,
Gia_Man_t * p,
Vec_Wec_t * vSupps,
int nCubeLim,
int nBTLimit,
int nCostMax,
int fCanon,
int fReverse,
int fCnfShared,
int fVerbose )

Definition at line 786 of file abcCollapse.c.

787{
788 ProgressBar * pProgress;
789 abctime clk = Abc_Clock();
790 Vec_Ptr_t * vSops = NULL, * vSopsRepr;
791 Vec_Int_t * vReprs, * vClass, * vReprSuppSizes;
792 int i, k, Entry, iCo, * pOrder;
793 Vec_Wec_t * vClasses;
794 Cnf_Dat_t * pCnf = NULL;
795 Vec_Int_t * vMap = NULL;
796 // derive classes of outputs
797 vClasses = Gia_ManIsoStrashReduceInt( p, vSupps, 0 );
798 if ( fVerbose )
799 {
800 printf( "Considering %d (out of %d) outputs. ", Vec_WecSize(vClasses), Gia_ManCoNum(p) );
801 Abc_PrintTime( 1, "Reduction time", Abc_Clock() - clk );
802 }
803 // derive representatives
804 vReprs = Vec_WecCollectFirsts( vClasses );
805 vReprSuppSizes = Vec_IntAlloc( Vec_IntSize(vReprs) );
806 Vec_IntForEachEntry( vReprs, Entry, i )
807 Vec_IntPush( vReprSuppSizes, Vec_IntSize(Vec_WecEntry(vSupps, Entry)) );
808 pOrder = Abc_MergeSortCost( Vec_IntArray(vReprSuppSizes), Vec_IntSize(vReprSuppSizes) );
809 Vec_IntFree( vReprSuppSizes );
810 // consider SOPs for representatives
811 if ( fCnfShared )
812 {
813 vMap = Vec_IntStartFull( Gia_ManObjNum(p) );
814 pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8, 1, 0, 0, 0 );
815 }
816 vSopsRepr = Vec_PtrStart( Vec_IntSize(vReprs) );
817 pProgress = Extra_ProgressBarStart( stdout, Vec_IntSize(vReprs) );
818 Extra_ProgressBarUpdate( pProgress, 0, NULL );
819 for ( i = 0; i < Vec_IntSize(vReprs); i++ )
820 {
821 int iEntry = pOrder[Vec_IntSize(vReprs) - 1 - i];
822 int iCoThis = Vec_IntEntry( vReprs, iEntry );
823 Vec_Int_t * vSupp = Vec_WecEntry( vSupps, iCoThis );
824 Vec_Str_t * vSop;
825 if ( Vec_IntSize(vSupp) < 2 )
826 {
827 Vec_PtrWriteEntry( vSopsRepr, iEntry, (void *)(ABC_PTRINT_T)1 );
828 continue;
829 }
830 if ( fCnfShared && !fCanon )
831 vSop = Abc_NtkClpGiaOne2( pCnf, p, iCoThis, nCubeLim, nBTLimit, fCanon, fReverse, vSupp, vMap, i ? 0 : fVerbose, Vec_WecEntry(vClasses, iEntry), vSupps );
832 else
833 vSop = Abc_NtkClpGiaOne( p, iCoThis, nCubeLim, nBTLimit, fCanon, fReverse, vSupp, i ? 0 : fVerbose, Vec_WecEntry(vClasses, iEntry), vSupps );
834 if ( vSop == NULL )
835 goto finish;
836 assert( Vec_IntSize( Vec_WecEntry(vSupps, iCoThis) ) == Abc_SopGetVarNum(Vec_StrArray(vSop)) );
837 Extra_ProgressBarUpdate( pProgress, i, NULL );
838 Vec_PtrWriteEntry( vSopsRepr, iEntry, Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Vec_StrArray(vSop) ) );
839 Vec_StrFree( vSop );
840 }
841 Extra_ProgressBarStop( pProgress );
842 if ( fCnfShared )
843 {
844 Cnf_DataFree( pCnf );
845 Vec_IntFree( vMap );
846 }
847 // derive SOPs for each output
848 vSops = Vec_PtrStart( Gia_ManCoNum(p) );
849 Vec_WecForEachLevel ( vClasses, vClass, i )
850 Vec_IntForEachEntry( vClass, iCo, k )
851 Vec_PtrWriteEntry( vSops, iCo, Vec_PtrEntry(vSopsRepr, i) );
852 assert( Vec_PtrCountZero(vSops) == 0 );
853/*
854 // verify
855 for ( i = 0; i < Gia_ManCoNum(p); i++ )
856 {
857 Vec_Int_t * vSupp = Vec_WecEntry( vSupps, i );
858 char * pSop = (char *)Vec_PtrEntry( vSops, i );
859 assert( Vec_IntSize(vSupp) == Abc_SopGetVarNum(pSop) );
860 }
861*/
862 // cleanup
863finish:
864 ABC_FREE( pOrder );
865 Vec_IntFree( vReprs );
866 Vec_WecFree( vClasses );
867 Vec_PtrFree( vSopsRepr );
868 return vSops;
869}
Vec_Str_t * Abc_NtkClpGiaOne(Gia_Man_t *p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t *vSupp, int fVerbose, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
Vec_Wec_t * Gia_ManIsoStrashReduceInt(Gia_Man_t *p, Vec_Wec_t *vSupps, int fVerbose)
Definition giaDup.c:4601
Vec_Str_t * Abc_NtkClpGiaOne2(Cnf_Dat_t *pCnf, Gia_Man_t *p, int iCo, int nCubeLim, int nBTLimit, int fCanon, int fReverse, Vec_Int_t *vSupp, Vec_Int_t *vMap, int fVerbose, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
ABC_INT64_T abctime
Definition abc_global.h:332
int * Abc_MergeSortCost(int *pCosts, int nSize)
Definition utilSort.c:442
#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
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
Cube * p
Definition exorList.c:222
void Extra_ProgressBarStop(ProgressBar *p)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void * pManFunc
Definition abc.h:191
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkClpDeriveSatSolver()

sat_solver * Abc_NtkClpDeriveSatSolver ( Cnf_Dat_t * pCnf,
int iCoObjId,
Vec_Int_t * vSupp,
Vec_Int_t * vAnds,
Vec_Int_t * vMap,
sat_solver ** ppSat1,
sat_solver ** ppSat2,
sat_solver ** ppSat3 )

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

Synopsis [Derives SAT solver for one output from the shared CNF.]

Description []

SideEffects []

SeeAlso []

Definition at line 666 of file abcCollapse.c.

667{
668 int i, k, iObj, status, nVars = 2;
669// int i, k, iObj, status, nVars = 1;
670 Vec_Int_t * vLits = Vec_IntAlloc( 16 );
671 sat_solver * pSat = sat_solver_new();
672 if ( ppSat1 ) *ppSat1 = sat_solver_new();
673 if ( ppSat2 ) *ppSat2 = sat_solver_new();
674 if ( ppSat3 ) *ppSat3 = sat_solver_new();
675 // assign SAT variable numbers
676 Vec_IntWriteEntry( vMap, iCoObjId, nVars++ );
677 Vec_IntForEachEntry( vSupp, iObj, k )
678 Vec_IntWriteEntry( vMap, iObj, nVars++ );
679 Vec_IntForEachEntry( vAnds, iObj, k )
680 if ( pCnf->pObj2Clause[iObj] != -1 )
681 Vec_IntWriteEntry( vMap, iObj, nVars++ );
682// Vec_IntForEachEntry( vSupp, iObj, k )
683// Vec_IntWriteEntry( vMap, iObj, nVars++ );
684 // create clauses for the internal nodes and for the output
685 sat_solver_setnvars( pSat, nVars );
686 if ( ppSat1 ) sat_solver_setnvars( *ppSat1, nVars );
687 if ( ppSat2 ) sat_solver_setnvars( *ppSat2, nVars );
688 if ( ppSat3 ) sat_solver_setnvars( *ppSat3, nVars );
689 Vec_IntPush( vAnds, iCoObjId );
690 Vec_IntForEachEntry( vAnds, iObj, k )
691 {
692 int iClaBeg, iClaEnd, * pLit;
693 if ( pCnf->pObj2Clause[iObj] == -1 )
694 continue;
695 iClaBeg = pCnf->pObj2Clause[iObj];
696 iClaEnd = iClaBeg + pCnf->pObj2Count[iObj];
697 assert( iClaBeg < iClaEnd );
698 for ( i = iClaBeg; i < iClaEnd; i++ )
699 {
700 Vec_IntClear( vLits );
701 for ( pLit = pCnf->pClauses[i]; pLit < pCnf->pClauses[i+1]; pLit++ )
702 Vec_IntPush( vLits, Abc_Lit2LitV(Vec_IntArray(vMap), *pLit) );
703 status = sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
704 assert( status );
705 (void) status;
706 if ( ppSat1 ) sat_solver_addclause( *ppSat1, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
707 if ( ppSat2 ) sat_solver_addclause( *ppSat2, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
708 if ( ppSat3 ) sat_solver_addclause( *ppSat3, Vec_IntArray(vLits), Vec_IntArray(vLits)+Vec_IntSize(vLits) );
709 }
710 }
711 Vec_IntPop( vAnds );
712 Vec_IntFree( vLits );
713 assert( nVars == sat_solver_nvars(pSat) );
714 return pSat;
715}
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
int * pObj2Count
Definition cnf.h:65
int * pObj2Clause
Definition cnf.h:64
int ** pClauses
Definition cnf.h:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkClpGia()

Gia_Man_t * Abc_NtkClpGia ( Abc_Ntk_t * pNtk)

Definition at line 574 of file abcCollapse.c.

575{
576 int i, iLit;
577 Gia_Man_t * pNew;
578 Abc_Obj_t * pNode;
579 assert( Abc_NtkIsStrash(pNtk) );
580 pNew = Gia_ManStart( 1000 );
581 pNew->pName = Abc_UtilStrsav( pNtk->pName );
582 pNew->pSpec = Abc_UtilStrsav( pNtk->pSpec );
583 Abc_NtkForEachObj( pNtk, pNode, i )
584 pNode->iTemp = -1;
585 Abc_AigConst1(pNtk)->iTemp = 1;
586 Abc_NtkForEachCi( pNtk, pNode, i )
587 pNode->iTemp = Gia_ManAppendCi(pNew);
588 Abc_NtkForEachCo( pNtk, pNode, i )
589 {
590 iLit = Abc_NtkClpGia_rec( pNew, Abc_ObjFanin0(pNode) );
591 iLit = Abc_LitNotCond( iLit, Abc_ObjFaninC0(pNode) );
592 Gia_ManAppendCo( pNew, iLit );
593 }
594 return pNew;
595}
int Abc_NtkClpGia_rec(Gia_Man_t *pNew, Abc_Obj_t *pNode)
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
char * pName
Definition abc.h:158
char * pSpec
Definition abc.h:159
int iTemp
Definition abc.h:149
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkClpGia_rec()

int Abc_NtkClpGia_rec ( Gia_Man_t * pNew,
Abc_Obj_t * pNode )

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

Synopsis [Derives GIA for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 562 of file abcCollapse.c.

563{
564 int iLit0, iLit1;
565 if ( pNode->iTemp >= 0 )
566 return pNode->iTemp;
567 assert( Abc_ObjIsNode( pNode ) );
568 iLit0 = Abc_NtkClpGia_rec( pNew, Abc_ObjFanin0(pNode) );
569 iLit1 = Abc_NtkClpGia_rec( pNew, Abc_ObjFanin1(pNode) );
570 iLit0 = Abc_LitNotCond( iLit0, Abc_ObjFaninC0(pNode) );
571 iLit1 = Abc_LitNotCond( iLit1, Abc_ObjFaninC1(pNode) );
572 return (pNode->iTemp = Gia_ManAppendAnd(pNew, iLit0, iLit1));
573}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkClpGiaOne()

Vec_Str_t * Abc_NtkClpGiaOne ( Gia_Man_t * p,
int iCo,
int nCubeLim,
int nBTLimit,
int fCanon,
int fReverse,
Vec_Int_t * vSupp,
int fVerbose,
Vec_Int_t * vClass,
Vec_Wec_t * vSupps )

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

Synopsis [Computes SOPs for each output.]

Description []

SideEffects []

SeeAlso []

Definition at line 728 of file abcCollapse.c.

729{
730 Vec_Str_t * vSop;
731 abctime clk = Abc_Clock();
732 extern Vec_Str_t * Bmc_CollapseOneOld( Gia_Man_t * p, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
733 Gia_Man_t * pGia = Gia_ManDupCones( p, &iCo, 1, 1 );
734 if ( fVerbose )
735 printf( "Output %4d: Supp = %4d. Cone =%6d.\n", iCo, Vec_IntSize(vSupp), Gia_ManAndNum(pGia) );
736 vSop = Bmc_CollapseOneOld( pGia, nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
737 Gia_ManStop( pGia );
738 if ( vSop == NULL )
739 return NULL;
740 Abc_NtkCollapseReduce( vSop, vSupp, vClass, vSupps );
741 if ( fVerbose )
742 printf( "Supp new = %4d. Sop = %4d. ", Vec_IntSize(vSupp), Vec_StrSize(vSop)/(Vec_IntSize(vSupp) +3) );
743 if ( fVerbose )
744 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
745 return vSop;
746}
int Abc_NtkCollapseReduce(Vec_Str_t *vSop, Vec_Int_t *vSupp, Vec_Int_t *vClass, Vec_Wec_t *vSupps)
Vec_Str_t * Bmc_CollapseOneOld(Gia_Man_t *p, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:864
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition giaDup.c:3880
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkClpGiaOne2()

Vec_Str_t * Abc_NtkClpGiaOne2 ( Cnf_Dat_t * pCnf,
Gia_Man_t * p,
int iCo,
int nCubeLim,
int nBTLimit,
int fCanon,
int fReverse,
Vec_Int_t * vSupp,
Vec_Int_t * vMap,
int fVerbose,
Vec_Int_t * vClass,
Vec_Wec_t * vSupps )

Definition at line 747 of file abcCollapse.c.

748{
749 Vec_Str_t * vSop;
750 sat_solver * pSat, * pSat1 = NULL, * pSat2 = NULL, * pSat3 = NULL;
751 Gia_Obj_t * pObj;
752 abctime clk = Abc_Clock();
753 extern Vec_Str_t * Bmc_CollapseOne_int( sat_solver * pSat, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
754 extern Vec_Str_t * Bmc_CollapseOne_int2( sat_solver * pSat, sat_solver * pSat2, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
755 extern Vec_Str_t * Bmc_CollapseOne_int3( sat_solver * pSat, sat_solver * pSat1, sat_solver * pSat2, sat_solver * pSat3, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose );
756 int i, iCoObjId = Gia_ObjId( p, Gia_ManCo(p, iCo) );
757 Vec_Int_t * vAnds = Vec_IntAlloc( 100 );
758 Vec_Int_t * vSuppObjs = Vec_IntAlloc( 100 );
759 Gia_ManForEachCiVec( vSupp, p, pObj, i )
760 Vec_IntPush( vSuppObjs, Gia_ObjId(p, pObj) );
762 Gia_ManCollectAnds( p, &iCoObjId, 1, vAnds, NULL );
763 assert( Vec_IntSize(vAnds) > 0 );
764// pSat = Abc_NtkClpDeriveSatSolver( pCnf, iCoObjId, vSuppObjs, vAnds, vMap, &pSat1, &pSat2, &pSat3 );
765 pSat = Abc_NtkClpDeriveSatSolver( pCnf, iCoObjId, vSuppObjs, vAnds, vMap, NULL, NULL, NULL );
766 Vec_IntFree( vSuppObjs );
767 if ( fVerbose )
768 printf( "Output %4d: Supp = %4d. Cone =%6d.\n", iCo, Vec_IntSize(vSupp), Vec_IntSize(vAnds) );
769// vSop = Bmc_CollapseOne_int3( pSat, pSat1, pSat2, pSat3, Vec_IntSize(vSupp), nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
770// vSop = Bmc_CollapseOne_int2( pSat, pSat1, Vec_IntSize(vSupp), nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
771 vSop = Bmc_CollapseOne_int( pSat, Vec_IntSize(vSupp), nCubeLim, nBTLimit, fCanon, fReverse, fVerbose );
772 sat_solver_delete( pSat );
773 if ( pSat1 ) sat_solver_delete( pSat1 );
774 if ( pSat2 ) sat_solver_delete( pSat2 );
775 if ( pSat3 ) sat_solver_delete( pSat3 );
776 Vec_IntFree( vAnds );
777 if ( vSop == NULL )
778 return NULL;
779 Abc_NtkCollapseReduce( vSop, vSupp, vClass, vSupps );
780 if ( fVerbose )
781 printf( "Supp new = %4d. Sop = %4d. ", Vec_IntSize(vSupp), Vec_StrSize(vSop)/(Vec_IntSize(vSupp) +3) );
782 if ( fVerbose )
783 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
784 return vSop;
785}
sat_solver * Abc_NtkClpDeriveSatSolver(Cnf_Dat_t *pCnf, int iCoObjId, Vec_Int_t *vSupp, Vec_Int_t *vAnds, Vec_Int_t *vMap, sat_solver **ppSat1, sat_solver **ppSat2, sat_solver **ppSat3)
Vec_Str_t * Bmc_CollapseOne_int(sat_solver *pSat, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1389
Vec_Str_t * Bmc_CollapseOne_int2(sat_solver *pSat1, sat_solver *pSat2, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1226
Vec_Str_t * Bmc_CollapseOne_int3(sat_solver *pSat0, sat_solver *pSat1, sat_solver *pSat2, sat_solver *pSat3, int nVars, int nCubeLim, int nBTLimit, int fCanon, int fReverse, int fVerbose)
Definition bmcClp.c:1040
#define Gia_ManForEachCiVec(vVec, p, pObj, i)
Definition gia.h:1232
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
void Gia_ManCollectAnds(Gia_Man_t *p, int *pNodes, int nNodes, Vec_Int_t *vNodes, Vec_Int_t *vLeaves)
Definition giaDfs.c:125
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkCollapse()

ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkCollapse ( Abc_Ntk_t * pNtk,
int fBddSizeMax,
int fDualRail,
int fReorder,
int fReverse,
int fDumpOrder,
int fVerbose )

DECLARATIONS ///.

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

FileName [abcCollapse.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Collapsing the network into two-levels.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 250 of file abcCollapse.c.

251{
252 return NULL;
253}
Here is the caller graph for this function:

◆ Abc_NtkCollapseReduce()

int Abc_NtkCollapseReduce ( Vec_Str_t * vSop,
Vec_Int_t * vSupp,
Vec_Int_t * vClass,
Vec_Wec_t * vSupps )

Definition at line 610 of file abcCollapse.c.

611{
612 int j = 0, i, k, iCo, iVar, nVars = Vec_IntSize(vSupp);
613 char * pCube, * pSop = Vec_StrArray(vSop);
614 Vec_Int_t * vPres;
615 if ( Vec_StrSize(vSop) == 4 ) // constant
616 {
617 Vec_IntForEachEntry( vClass, iCo, i )
618 Vec_IntClear( Vec_WecEntry(vSupps, iCo) );
619 return 1;
620 }
621 vPres = Vec_IntStart( nVars );
622 Abc_NtkSopForEachCube( pSop, nVars, pCube )
623 for ( k = 0; k < nVars; k++ )
624 if ( pCube[k] != '-' )
625 Vec_IntWriteEntry( vPres, k, 1 );
626 if ( Vec_IntCountZero(vPres) == 0 )
627 {
628 Vec_IntFree( vPres );
629 return 0;
630 }
631 // reduce cubes
632 Abc_NtkSopForEachCube( pSop, nVars, pCube )
633 for ( k = 0; k < nVars + 3; k++ )
634 if ( k >= nVars || Vec_IntEntry(vPres, k) )
635 Vec_StrWriteEntry( vSop, j++, pCube[k] );
636 Vec_StrWriteEntry( vSop, j++, '\0' );
637 Vec_StrShrink( vSop, j );
638 // reduce support
639 Vec_IntForEachEntry( vClass, iCo, i )
640 {
641 j = 0;
642 vSupp = Vec_WecEntry( vSupps, iCo );
643 Vec_IntForEachEntry( vSupp, iVar, k )
644 if ( Vec_IntEntry(vPres, k) )
645 Vec_IntWriteEntry( vSupp, j++, iVar );
646 Vec_IntShrink( vSupp, j );
647 }
648 Vec_IntFree( vPres );
649// if ( Vec_IntSize(vSupp) != Abc_SopGetVarNum(Vec_StrArray(vSop)) )
650// printf( "Mismatch!!!\n" );
651 return 1;
652}
#define Abc_NtkSopForEachCube(pSop, nVars, pCube)
Here is the caller graph for this function:

◆ Abc_NtkCollapseSat()

Abc_Ntk_t * Abc_NtkCollapseSat ( Abc_Ntk_t * pNtk,
int nCubeLim,
int nBTLimit,
int nCostMax,
int fCanon,
int fReverse,
int fCnfShared,
int fVerbose )

Definition at line 943 of file abcCollapse.c.

944{
945 Abc_Ntk_t * pNtkNew;
946 assert( Abc_NtkIsStrash(pNtk) );
947 pNtkNew = Abc_NtkFromSopsInt( pNtk, nCubeLim, nBTLimit, nCostMax, fCanon, fReverse, fCnfShared, fVerbose );
948 if ( pNtkNew == NULL )
949 return NULL;
950 if ( pNtk->pExdc )
951 pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
952 if ( !Abc_NtkCheck( pNtkNew ) )
953 {
954 printf( "Abc_NtkCollapseSat: The network check has failed.\n" );
955 Abc_NtkDelete( pNtkNew );
956 return NULL;
957 }
958 return pNtkNew;
959}
Abc_Ntk_t * Abc_NtkFromSopsInt(Abc_Ntk_t *pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
Abc_Ntk_t * pExdc
Definition abc.h:201
Here is the call graph for this function:

◆ Abc_NtkFromSopsInt()

Abc_Ntk_t * Abc_NtkFromSopsInt ( Abc_Ntk_t * pNtk,
int nCubeLim,
int nBTLimit,
int nCostMax,
int fCanon,
int fReverse,
int fCnfShared,
int fVerbose )

Definition at line 870 of file abcCollapse.c.

871{
872 Abc_Ntk_t * pNtkNew;
873 Gia_Man_t * pGia;
874 Vec_Wec_t * vSupps;
875 Vec_Int_t * vSupp;
876 Vec_Ptr_t * vSops;
877 Abc_Obj_t * pNode, * pNodeNew, * pDriver;
878 int i, k, iCi;
879 pGia = Abc_NtkClpGia( pNtk );
880 vSupps = Gia_ManCreateCoSupps( pGia, fVerbose );
881 // check the largest output
882 if ( nCubeLim > 0 && nCostMax > 0 )
883 {
884 int iCoMax = Gia_ManCoLargestSupp( pGia, vSupps );
885 int iObjMax = Gia_ObjId( pGia, Gia_ManCo(pGia, iCoMax) );
886 int nSuppMax = Vec_IntSize( Vec_WecEntry(vSupps, iCoMax) );
887 int nNodeMax = Gia_ManConeSize( pGia, &iObjMax, 1 );
888 word Cost = (word)nNodeMax * (word)nSuppMax * (word)nCubeLim;
889 if ( Cost > (word)nCostMax )
890 {
891 printf( "Cost of the largest output cone exceeded the limit (%d * %d * %d > %d).\n",
892 nNodeMax, nSuppMax, nCubeLim, nCostMax );
893 Gia_ManStop( pGia );
894 Vec_WecFree( vSupps );
895 return NULL;
896 }
897 }
898 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
899 vSops = Abc_GiaDeriveSops( pNtkNew, pGia, vSupps, nCubeLim, nBTLimit, nCostMax, fCanon, fReverse, fCnfShared, fVerbose );
900 Gia_ManStop( pGia );
901 if ( vSops == NULL )
902 {
903 Vec_WecFree( vSupps );
904 Abc_NtkDelete( pNtkNew );
905 return NULL;
906 }
907 Abc_NtkForEachCo( pNtk, pNode, i )
908 {
909 pDriver = Abc_ObjFanin0(pNode);
910 if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
911 {
912 Abc_ObjAddFanin( pNode->pCopy, pDriver->pCopy );
913 continue;
914 }
915 if ( Abc_ObjIsCi(pDriver) )
916 {
917 pNodeNew = Abc_NtkCreateNode( pNtkNew );
918 Abc_ObjAddFanin( pNodeNew, pDriver->pCopy );
919 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pNode) ? "0 1\n" : "1 1\n" );
920 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
921 continue;
922 }
923 if ( pDriver == Abc_AigConst1(pNtk) )
924 {
925 pNodeNew = Abc_NtkCreateNode( pNtkNew );
926 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pNode) ? " 0\n" : " 1\n" );
927 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
928 continue;
929 }
930 pNodeNew = Abc_NtkCreateNode( pNtkNew );
931 vSupp = Vec_WecEntry( vSupps, i );
932 Vec_IntForEachEntry( vSupp, iCi, k )
933 Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, iCi) );
934 pNodeNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, (const char*)Vec_PtrEntry( vSops, i ) );
935 assert( pNodeNew->pData != (void *)(ABC_PTRINT_T)1 );
936 Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
937 }
938 Vec_WecFree( vSupps );
939 Vec_PtrFree( vSops );
940 Abc_NtkSortSops( pNtkNew );
941 return pNtkNew;
942}
Vec_Ptr_t * Abc_GiaDeriveSops(Abc_Ntk_t *pNtkNew, Gia_Man_t *p, Vec_Wec_t *vSupps, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose)
int Gia_ManCoLargestSupp(Gia_Man_t *p, Vec_Wec_t *vSupps)
Definition giaDup.c:4452
Vec_Wec_t * Gia_ManCreateCoSupps(Gia_Man_t *p, int fVerbose)
Definition giaDup.c:4421
Gia_Man_t * Abc_NtkClpGia(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL void Abc_NtkSortSops(Abc_Ntk_t *pNtk)
@ ABC_FUNC_SOP
Definition abc.h:65
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:157
int Gia_ManConeSize(Gia_Man_t *p, int *pNodes, int nNodes)
Definition giaDfs.c:375
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int nSuppMax
Definition llb3Image.c:83
void * pData
Definition abc.h:145
Abc_Obj_t * pCopy
Definition abc.h:148
int strcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCoLargestSupp()

int Gia_ManCoLargestSupp ( Gia_Man_t * p,
Vec_Wec_t * vSupps )
extern

Definition at line 4452 of file giaDup.c.

4453{
4454 Gia_Obj_t * pObj;
4455 Vec_Int_t * vSuppOne;
4456 int i, iCoMax = -1, nSuppMax = -1;
4457 Gia_ManForEachCo( p, pObj, i )
4458 {
4459 vSuppOne = Vec_WecEntry( vSupps, i );
4460 if ( nSuppMax < Vec_IntSize(vSuppOne) )
4461 {
4462 nSuppMax = Vec_IntSize(vSuppOne);
4463 iCoMax = i;
4464 }
4465 }
4466 return iCoMax;
4467}
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
Here is the caller graph for this function:

◆ Gia_ManCreateCoSupps()

Vec_Wec_t * Gia_ManCreateCoSupps ( Gia_Man_t * p,
int fVerbose )
extern

Definition at line 4421 of file giaDup.c.

4422{
4423 abctime clk = Abc_Clock();
4424 Gia_Obj_t * pObj; int i, Id;
4425 Vec_Wec_t * vSuppsCo = Vec_WecStart( Gia_ManCoNum(p) );
4426 Vec_Wec_t * vSupps = Vec_WecStart( Gia_ManObjNum(p) );
4427 Gia_ManForEachCiId( p, Id, i )
4428 Vec_IntPush( Vec_WecEntry(vSupps, Id), i );
4429 Gia_ManForEachAnd( p, pObj, Id )
4430 Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Gia_ObjFaninId0(pObj, Id)),
4431 Vec_WecEntry(vSupps, Gia_ObjFaninId1(pObj, Id)),
4432 Vec_WecEntry(vSupps, Id) );
4433 Gia_ManForEachCo( p, pObj, i )
4434 Vec_IntAppend( Vec_WecEntry(vSuppsCo, i), Vec_WecEntry(vSupps, Gia_ObjFaninId0p(p, pObj)) );
4435 Vec_WecFree( vSupps );
4436 if ( fVerbose )
4437 Abc_PrintTime( 1, "Support computation", Abc_Clock() - clk );
4438 return vSuppsCo;
4439}
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230
Here is the caller graph for this function:

◆ Gia_ManIsoStrashReduceInt()

Vec_Wec_t * Gia_ManIsoStrashReduceInt ( Gia_Man_t * p,
Vec_Wec_t * vSupps,
int fVerbose )
extern

Definition at line 4601 of file giaDup.c.

4602{
4603 Gia_Man_t * pNew;
4604 Gia_Obj_t * pObj;
4605 Vec_Wec_t * vPosEquivs = Vec_WecAlloc( 100 );
4606 Vec_Int_t * vSuppOne, * vMap = Vec_IntAlloc( 10000 );
4607 int i, iLit, nSuppMax = Gia_ManCoSuppSizeMax( p, vSupps );
4608 // count how many times each support size appears
4609 Vec_Int_t * vSizeCount = Vec_IntStart( nSuppMax + 1 );
4610 Vec_WecForEachLevel( vSupps, vSuppOne, i )
4611 Vec_IntAddToEntry( vSizeCount, Vec_IntSize(vSuppOne), 1 );
4612 // create array of unique outputs
4614 pNew = Gia_ManStart( Gia_ManObjNum(p) );
4615 Gia_ManConst0(p)->Value = 0;
4616 for ( i = 0; i < nSuppMax; i++ )
4617 Gia_ManAppendCi(pNew);
4618 Gia_ManHashAlloc( pNew );
4619 Gia_ManForEachCo( p, pObj, i )
4620 {
4621 vSuppOne = Vec_WecEntry( vSupps, i );
4622 if ( Vec_IntEntry(vSizeCount, Vec_IntSize(vSuppOne)) == 1 )
4623 {
4624 Vec_IntPush( Vec_WecPushLevel(vPosEquivs), i );
4625 continue;
4626 }
4627 iLit = Gia_ManIsoStrashReduceOne( pNew, p, pObj, vSuppOne );
4628 Vec_IntFillExtra( vMap, iLit + 1, -1 );
4629 if ( Vec_IntEntry(vMap, iLit) == -1 )
4630 {
4631 Vec_IntWriteEntry( vMap, iLit, Vec_WecSize(vPosEquivs) );
4632 Vec_IntPush( Vec_WecPushLevel(vPosEquivs), i );
4633 continue;
4634 }
4635 Vec_IntPush( Vec_WecEntry(vPosEquivs, Vec_IntEntry(vMap, iLit)), i );
4636 }
4637 Gia_ManHashStop( pNew );
4638 Gia_ManStop( pNew );
4639 Vec_IntFree( vSizeCount );
4640 Vec_IntFree( vMap );
4641 return vPosEquivs;
4642}
int Gia_ManIsoStrashReduceOne(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSupp)
Definition giaDup.c:4586
int Gia_ManCoSuppSizeMax(Gia_Man_t *p, Vec_Wec_t *vSupps)
Definition giaDup.c:4440
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
Here is the call graph for this function:
Here is the caller graph for this function: