ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sbdCut.c File Reference
#include "sbdInt.h"
Include dependency graph for sbdCut.c:

Go to the source code of this file.

Classes

struct  Sbd_Cut_t_
 
struct  Sbd_Sto_t_
 

Macros

#define SBD_MAX_CUTSIZE   10
 DECLARATIONS ///.
 
#define SBD_MAX_CUTNUM   501
 
#define SBD_MAX_TT_WORDS   ((SBD_MAX_CUTSIZE > 6) ? 1 << (SBD_MAX_CUTSIZE-6) : 1)
 
#define SBD_CUT_NO_LEAF   0xF
 
#define Sbd_ForEachCut(pList, pCut, i)
 

Typedefs

typedef struct Sbd_Cut_t_ Sbd_Cut_t
 

Functions

void Sbd_StoMergeCuts (Sbd_Sto_t *p, int iObj)
 
Sbd_Sto_tSbd_StoAlloc (Gia_Man_t *pGia, Vec_Int_t *vMirrors, int nLutSize, int nCutSize, int nCutNum, int fCutMin, int fVerbose)
 MACRO DEFINITIONS ///.
 
void Sbd_StoFree (Sbd_Sto_t *p)
 
void Sbd_StoComputeCutsObj (Sbd_Sto_t *p, int iObj, int Delay, int Level)
 
void Sbd_StoComputeCutsConst0 (Sbd_Sto_t *p, int iObj)
 
void Sbd_StoComputeCutsCi (Sbd_Sto_t *p, int iObj, int Delay, int Level)
 
int Sbd_StoComputeCutsNode (Sbd_Sto_t *p, int iObj)
 
void Sbd_StoSaveBestDelayCut (Sbd_Sto_t *p, int iObj, int *pCut)
 
int Sbd_StoObjRefs (Sbd_Sto_t *p, int iObj)
 
void Sbd_StoRefObj (Sbd_Sto_t *p, int iObj, int iMirror)
 
void Sbd_StoDerefObj (Sbd_Sto_t *p, int iObj)
 
int Sbd_StoObjBestCut (Sbd_Sto_t *p, int iObj, int nSize, int *pLeaves)
 
void Sbd_StoComputeCutsTest (Gia_Man_t *pGia)
 

Macro Definition Documentation

◆ SBD_CUT_NO_LEAF

#define SBD_CUT_NO_LEAF   0xF

Definition at line 34 of file sbdCut.c.

◆ Sbd_ForEachCut

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

Definition at line 78 of file sbdCut.c.

◆ SBD_MAX_CUTNUM

#define SBD_MAX_CUTNUM   501

Definition at line 31 of file sbdCut.c.

◆ SBD_MAX_CUTSIZE

#define SBD_MAX_CUTSIZE   10

DECLARATIONS ///.

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

FileName [sbdCut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based optimization using internal don't-cares.]

Synopsis [Cut computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 30 of file sbdCut.c.

◆ SBD_MAX_TT_WORDS

#define SBD_MAX_TT_WORDS   ((SBD_MAX_CUTSIZE > 6) ? 1 << (SBD_MAX_CUTSIZE-6) : 1)

Definition at line 32 of file sbdCut.c.

Typedef Documentation

◆ Sbd_Cut_t

typedef struct Sbd_Cut_t_ Sbd_Cut_t

Definition at line 36 of file sbdCut.c.

Function Documentation

◆ Sbd_StoAlloc()

Sbd_Sto_t * Sbd_StoAlloc ( Gia_Man_t * pGia,
Vec_Int_t * vMirrors,
int nLutSize,
int nCutSize,
int nCutNum,
int fCutMin,
int fVerbose )

MACRO DEFINITIONS ///.

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

Synopsis [Incremental cut computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 667 of file sbdCut.c.

668{
669 Sbd_Sto_t * p;
670 assert( nLutSize <= nCutSize );
671 assert( nCutSize < SBD_CUT_NO_LEAF );
672 assert( nCutSize > 1 && nCutSize <= SBD_MAX_CUTSIZE );
673 assert( nCutNum > 1 && nCutNum < SBD_MAX_CUTNUM );
674 p = ABC_CALLOC( Sbd_Sto_t, 1 );
675 p->clkStart = Abc_Clock();
676 p->nLutSize = nLutSize;
677 p->nCutSize = nCutSize;
678 p->nCutNum = nCutNum;
679 p->fCutMin = fCutMin;
680 p->fVerbose = fVerbose;
681 p->pGia = pGia;
682 p->vMirrors = vMirrors;
683 p->vDelays = Vec_IntStart( Gia_ManObjNum(pGia) );
684 p->vLevels = Vec_IntStart( Gia_ManObjNum(pGia) );
685 p->vRefs = Vec_IntAlloc( Gia_ManObjNum(pGia) );
686 p->vCuts = Vec_WecStart( Gia_ManObjNum(pGia) );
687 p->vTtMem = fCutMin ? Vec_MemAllocForTT( nCutSize, 0 ) : NULL;
688 return p;
689}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Cube * p
Definition exorList.c:222
#define SBD_MAX_CUTSIZE
DECLARATIONS ///.
Definition sbdCut.c:30
#define SBD_CUT_NO_LEAF
Definition sbdCut.c:34
#define SBD_MAX_CUTNUM
Definition sbdCut.c:31
struct Sbd_Sto_t_ Sbd_Sto_t
BASIC TYPES ///.
Definition sbdInt.h:64
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Sbd_StoComputeCutsCi()

void Sbd_StoComputeCutsCi ( Sbd_Sto_t * p,
int iObj,
int Delay,
int Level )

Definition at line 724 of file sbdCut.c.

725{
726 Sbd_StoComputeCutsObj( p, iObj, Delay, Level );
727 Sbd_CutAddUnit( p, iObj );
728}
void Sbd_StoComputeCutsObj(Sbd_Sto_t *p, int iObj, int Delay, int Level)
Definition sbdCut.c:702
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbd_StoComputeCutsConst0()

void Sbd_StoComputeCutsConst0 ( Sbd_Sto_t * p,
int iObj )

Definition at line 719 of file sbdCut.c.

720{
721 Sbd_StoComputeCutsObj( p, iObj, 0, 0 );
722 Sbd_CutAddZero( p, iObj );
723}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbd_StoComputeCutsNode()

int Sbd_StoComputeCutsNode ( Sbd_Sto_t * p,
int iObj )

Definition at line 729 of file sbdCut.c.

730{
731 Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
732 int Lev0 = Vec_IntEntry( p->vLevels, Gia_ObjFaninId0(pObj, iObj) );
733 int Lev1 = Vec_IntEntry( p->vLevels, Gia_ObjFaninId1(pObj, iObj) );
734 Sbd_StoComputeCutsObj( p, iObj, -1, 1 + Abc_MaxInt(Lev0, Lev1) );
735 Sbd_StoMergeCuts( p, iObj );
736 return Vec_IntEntry( p->vDelays, iObj );
737}
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Sbd_StoMergeCuts(Sbd_Sto_t *p, int iObj)
Definition sbdCut.c:594
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbd_StoComputeCutsObj()

void Sbd_StoComputeCutsObj ( Sbd_Sto_t * p,
int iObj,
int Delay,
int Level )

Definition at line 702 of file sbdCut.c.

703{
704 if ( iObj < Vec_IntSize(p->vDelays) )
705 {
706 Vec_IntWriteEntry( p->vDelays, iObj, Delay );
707 Vec_IntWriteEntry( p->vLevels, iObj, Level );
708 }
709 else
710 {
711 assert( iObj == Vec_IntSize(p->vDelays) );
712 assert( iObj == Vec_IntSize(p->vLevels) );
713 assert( iObj == Vec_WecSize(p->vCuts) );
714 Vec_IntPush( p->vDelays, Delay );
715 Vec_IntPush( p->vLevels, Level );
716 Vec_WecPushLevel( p->vCuts );
717 }
718}
Here is the caller graph for this function:

◆ Sbd_StoComputeCutsTest()

void Sbd_StoComputeCutsTest ( Gia_Man_t * pGia)

Definition at line 833 of file sbdCut.c.

834{
835 Sbd_Sto_t * p = Sbd_StoAlloc( pGia, NULL, 4, 8, 100, 1, 1 );
836 Gia_Obj_t * pObj;
837 int i, iObj;
838 // prepare references
839 Gia_ManForEachObj( p->pGia, pObj, iObj )
840 Sbd_StoRefObj( p, iObj, -1 );
841 // compute cuts
843 Gia_ManForEachCiId( p->pGia, iObj, i )
844 Sbd_StoComputeCutsCi( p, iObj, 0, 0 );
845 Gia_ManForEachAnd( p->pGia, pObj, iObj )
846 Sbd_StoComputeCutsNode( p, iObj );
847 if ( p->fVerbose )
848 {
849 printf( "Running cut computation with LutSize = %d CutSize = %d CutNum = %d:\n", p->nLutSize, p->nCutSize, p->nCutNum );
850 printf( "CutPair = %.0f ", p->CutCount[0] );
851 printf( "Merge = %.0f (%.2f %%) ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
852 printf( "Eval = %.0f (%.2f %%) ", p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
853 printf( "Cut = %.0f (%.2f %%) ", p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
854 printf( "Cut/Node = %.2f ", p->CutCount[3] / Gia_ManAndNum(p->pGia) );
855 printf( "\n" );
856 printf( "Spec = %4d ", p->nCutsSpec );
857 printf( "Over = %4d ", p->nCutsOver );
858 printf( "Lev = %4d ", p->DelayMin );
859 Abc_PrintTime( 0, "Time", Abc_Clock() - p->clkStart );
860 }
861 Sbd_StoFree( p );
862}
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230
Sbd_Sto_t * Sbd_StoAlloc(Gia_Man_t *pGia, Vec_Int_t *vMirrors, int nLutSize, int nCutSize, int nCutNum, int fCutMin, int fVerbose)
MACRO DEFINITIONS ///.
Definition sbdCut.c:667
void Sbd_StoFree(Sbd_Sto_t *p)
Definition sbdCut.c:690
int Sbd_StoComputeCutsNode(Sbd_Sto_t *p, int iObj)
Definition sbdCut.c:729
void Sbd_StoComputeCutsConst0(Sbd_Sto_t *p, int iObj)
Definition sbdCut.c:719
void Sbd_StoRefObj(Sbd_Sto_t *p, int iObj, int iMirror)
Definition sbdCut.c:750
void Sbd_StoComputeCutsCi(Sbd_Sto_t *p, int iObj, int Delay, int Level)
Definition sbdCut.c:724
Here is the call graph for this function:

◆ Sbd_StoDerefObj()

void Sbd_StoDerefObj ( Sbd_Sto_t * p,
int iObj )

Definition at line 778 of file sbdCut.c.

779{
780 Gia_Obj_t * pObj;
781 int Lit0m, Lit1m, Fan0, Fan1;
782 return;
783
784 pObj = Gia_ManObj(p->pGia, iObj);
785 if ( Vec_IntEntry(p->vRefs, iObj) == 0 )
786 printf( "Ref count mismatch at node %d\n", iObj );
787 assert( Vec_IntEntry(p->vRefs, iObj) > 0 );
788 Vec_IntAddToEntry( p->vRefs, iObj, -1 );
789 if ( Vec_IntEntry( p->vRefs, iObj ) > 0 )
790 return;
791 if ( Gia_ObjIsCi(pObj) )
792 return;
793//printf( "Deref %d\n", iObj );
794 assert( Gia_ObjIsAnd(pObj) );
795 Lit0m = Vec_IntEntry( p->vMirrors, Gia_ObjFaninId0(pObj, iObj) );
796 Lit1m = Vec_IntEntry( p->vMirrors, Gia_ObjFaninId1(pObj, iObj) );
797 Fan0 = Lit0m >= 0 ? Abc_Lit2Var(Lit0m) : Gia_ObjFaninId0(pObj, iObj);
798 Fan1 = Lit1m >= 0 ? Abc_Lit2Var(Lit1m) : Gia_ObjFaninId1(pObj, iObj);
799 if ( Fan0 ) Sbd_StoDerefObj( p, Fan0 );
800 if ( Fan1 ) Sbd_StoDerefObj( p, Fan1 );
801}
void Sbd_StoDerefObj(Sbd_Sto_t *p, int iObj)
Definition sbdCut.c:778
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbd_StoFree()

void Sbd_StoFree ( Sbd_Sto_t * p)

Definition at line 690 of file sbdCut.c.

691{
692 Vec_IntFree( p->vDelays );
693 Vec_IntFree( p->vLevels );
694 Vec_IntFree( p->vRefs );
695 Vec_WecFree( p->vCuts );
696 if ( p->fCutMin )
697 Vec_MemHashFree( p->vTtMem );
698 if ( p->fCutMin )
699 Vec_MemFree( p->vTtMem );
700 ABC_FREE( p );
701}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Sbd_StoMergeCuts()

void Sbd_StoMergeCuts ( Sbd_Sto_t * p,
int iObj )

Definition at line 594 of file sbdCut.c.

595{
596 Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
597 int fIsXor = Gia_ObjIsXor(pObj);
598 int nCutSize = p->nCutSize;
599 int nCutNum = p->nCutNum;
600 int Lit0m = p->vMirrors ? Vec_IntEntry( p->vMirrors, Gia_ObjFaninId0(pObj, iObj) ) : -1;
601 int Lit1m = p->vMirrors ? Vec_IntEntry( p->vMirrors, Gia_ObjFaninId1(pObj, iObj) ) : -1;
602 int fComp0 = Gia_ObjFaninC0(pObj) ^ (Lit0m >= 0 && Abc_LitIsCompl(Lit0m));
603 int fComp1 = Gia_ObjFaninC1(pObj) ^ (Lit1m >= 0 && Abc_LitIsCompl(Lit1m));
604 int Fan0 = Lit0m >= 0 ? Abc_Lit2Var(Lit0m) : Gia_ObjFaninId0(pObj, iObj);
605 int Fan1 = Lit1m >= 0 ? Abc_Lit2Var(Lit1m) : Gia_ObjFaninId1(pObj, iObj);
606 int nCuts0 = Sbd_StoPrepareSet( p, Fan0, 0 );
607 int nCuts1 = Sbd_StoPrepareSet( p, Fan1, 1 );
608 int i, k, nCutsR = 0;
609 Sbd_Cut_t * pCut0, * pCut1, ** pCutsR = p->ppCuts;
610 assert( !Gia_ObjIsBuf(pObj) );
611 assert( !Gia_ObjIsMux(p->pGia, pObj) );
612 Sbd_StoInitResult( p );
613 p->CutCount[0] += nCuts0 * nCuts1;
614 for ( i = 0, pCut0 = p->pCuts[0]; i < nCuts0; i++, pCut0++ )
615 for ( k = 0, pCut1 = p->pCuts[1]; k < nCuts1; k++, pCut1++ )
616 {
617 if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nCutSize && Sbd_CutCountBits(pCut0->Sign | pCut1->Sign) > nCutSize )
618 continue;
619 p->CutCount[1]++;
620 if ( !Sbd_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nCutSize) )
621 continue;
622 if ( Sbd_CutSetLastCutIsContained(pCutsR, nCutsR) )
623 continue;
624 p->CutCount[2]++;
625 if ( p->fCutMin && Sbd_CutComputeTruth(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
626 pCutsR[nCutsR]->Sign = Sbd_CutGetSign(pCutsR[nCutsR]);
627 pCutsR[nCutsR]->Cost = Sbd_CutCost( p, pCutsR[nCutsR] );
628 pCutsR[nCutsR]->CostLev = Sbd_CutCostLev( p, pCutsR[nCutsR] );
629 pCutsR[nCutsR]->nTreeLeaves = Sbd_CutTreeLeaves( p, pCutsR[nCutsR] );
630 nCutsR = Sbd_CutSetAddCut( pCutsR, nCutsR, nCutNum );
631 }
632 Sbd_StoComputeDelay( p, iObj, pCutsR, nCutsR );
633 Sbd_StoComputeSpec( p, iObj, pCutsR, nCutsR );
634 p->CutCount[3] += nCutsR;
635 p->nCutsOver += nCutsR == nCutNum-1;
636 p->nCutsR = nCutsR;
637 p->Pivot = iObj;
638 // debug printout
639 if ( 0 )
640 {
641 printf( "*** Obj = %4d Delay = %4d NumCuts = %4d\n", iObj, Vec_IntEntry(p->vDelays, iObj), nCutsR );
642 for ( i = 0; i < nCutsR; i++ )
643 if ( (int)pCutsR[i]->nLeaves <= p->nLutSize || pCutsR[i]->nSlowLeaves < 2 )
644 Sbd_CutPrint( p, iObj, pCutsR[i] );
645 printf( "\n" );
646 }
647 // verify
648 assert( nCutsR > 0 && nCutsR < nCutNum );
649 assert( Sbd_CutSetCheckArray(pCutsR, nCutsR) );
650 // store the cutset
651 Sbd_StoStoreResult( p, iObj, pCutsR, nCutsR );
652 if ( nCutsR > 1 || pCutsR[0]->nLeaves > 1 )
653 Sbd_CutAddUnit( p, iObj );
654}
struct Sbd_Cut_t_ Sbd_Cut_t
Definition sbdCut.c:36
int Cost
Definition sbdCut.c:41
unsigned nLeaves
Definition sbdCut.c:46
int CostLev
Definition sbdCut.c:42
word Sign
Definition sbdCut.c:39
unsigned nTreeLeaves
Definition sbdCut.c:43
Here is the caller graph for this function:

◆ Sbd_StoObjBestCut()

int Sbd_StoObjBestCut ( Sbd_Sto_t * p,
int iObj,
int nSize,
int * pLeaves )

Definition at line 802 of file sbdCut.c.

803{
804 int fVerbose = 0;
805 Sbd_Cut_t * pCutBest = NULL; int i;
806 assert( p->Pivot == iObj );
807 if ( fVerbose && iObj % 1000 == 0 )
808 printf( "Node %6d : \n", iObj );
809 for ( i = 0; i < p->nCutsR; i++ )
810 {
811 if ( fVerbose && iObj % 1000 == 0 )
812 Sbd_CutPrint( p, iObj, p->ppCuts[i] );
813 if ( nSize && (int)p->ppCuts[i]->nLeaves != nSize )
814 continue;
815 if ( (int)p->ppCuts[i]->nLeaves > p->nLutSize &&
816 (int)p->ppCuts[i]->nSlowLeaves <= 1 &&
817 (int)p->ppCuts[i]->nTopLeaves <= p->nLutSize-1 &&
818 (pCutBest == NULL || Sbd_CutCompare2(pCutBest, p->ppCuts[i]) == 1) )
819 pCutBest = p->ppCuts[i];
820 }
821 if ( fVerbose && iObj % 1000 == 0 )
822 {
823 printf( "Best cut of size %d:\n", nSize );
824 Sbd_CutPrint( p, iObj, pCutBest );
825 }
826 if ( pCutBest == NULL )
827 return -1;
828 assert( pCutBest->nLeaves <= SBD_DIV_MAX );
829 for ( i = 0; i < (int)pCutBest->nLeaves; i++ )
830 pLeaves[i] = pCutBest->pLeaves[i];
831 return pCutBest->nLeaves;
832}
#define SBD_DIV_MAX
Definition sbdInt.h:57
int pLeaves[SBD_MAX_CUTSIZE]
Definition sbdCut.c:47
Here is the caller graph for this function:

◆ Sbd_StoObjRefs()

int Sbd_StoObjRefs ( Sbd_Sto_t * p,
int iObj )

Definition at line 746 of file sbdCut.c.

747{
748 return Vec_IntEntry(p->vRefs, iObj);
749}

◆ Sbd_StoRefObj()

void Sbd_StoRefObj ( Sbd_Sto_t * p,
int iObj,
int iMirror )

Definition at line 750 of file sbdCut.c.

751{
752 Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
753 assert( iObj == Vec_IntSize(p->vRefs) );
754 assert( iMirror < iObj );
755 Vec_IntPush( p->vRefs, 0 );
756//printf( "Ref %d\n", iObj );
757 if ( iMirror > 0 )
758 {
759 Vec_IntWriteEntry( p->vRefs, iObj, Vec_IntEntry(p->vRefs, iMirror) );
760 Vec_IntWriteEntry( p->vRefs, iMirror, 1 );
761 }
762 if ( Gia_ObjIsAnd(pObj) )
763 {
764 int Lit0m = Vec_IntEntry( p->vMirrors, Gia_ObjFaninId0(pObj, iObj) );
765 int Lit1m = Vec_IntEntry( p->vMirrors, Gia_ObjFaninId1(pObj, iObj) );
766 int Fan0 = Lit0m >= 0 ? Abc_Lit2Var(Lit0m) : Gia_ObjFaninId0(pObj, iObj);
767 int Fan1 = Lit1m >= 0 ? Abc_Lit2Var(Lit1m) : Gia_ObjFaninId1(pObj, iObj);
768 Vec_IntAddToEntry( p->vRefs, Fan0, 1 );
769 Vec_IntAddToEntry( p->vRefs, Fan1, 1 );
770 }
771 else if ( Gia_ObjIsCo(pObj) )
772 {
773 int Lit0m = Vec_IntEntry( p->vMirrors, Gia_ObjFaninId0(pObj, iObj) );
774 assert( Lit0m == -1 );
775 Vec_IntAddToEntry( p->vRefs, Gia_ObjFaninId0(pObj, iObj), 1 );
776 }
777}
Here is the caller graph for this function:

◆ Sbd_StoSaveBestDelayCut()

void Sbd_StoSaveBestDelayCut ( Sbd_Sto_t * p,
int iObj,
int * pCut )

Definition at line 738 of file sbdCut.c.

739{
740 Sbd_Cut_t * pCutBest = p->ppCuts[p->iCutBest]; int i;
741 assert( iObj == p->Pivot );
742 pCut[0] = pCutBest->nLeaves;
743 for ( i = 0; i < (int)pCutBest->nLeaves; i++ )
744 pCut[i+1] = pCutBest->pLeaves[i];
745}
Here is the caller graph for this function: