From a1e9f668a88f01dccda8da1bc5ca8e22211b1751 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 4 Oct 2015 17:45:24 -0700 Subject: Adding support for black boxes in extended AIG. --- src/aig/gia/gia.h | 1 + src/aig/gia/giaFadds.c | 2 +- src/aig/gia/giaMan.c | 2 + src/aig/gia/giaMfs.c | 110 ++++++++++++++++++++++++++++++++++-------------- src/aig/gia/giaTim.c | 16 +++++-- src/base/abci/abcTim.c | 2 +- src/base/wlc/wlcBlast.c | 2 +- src/misc/tim/tim.h | 3 +- src/misc/tim/timBox.c | 3 +- src/misc/tim/timDump.c | 6 ++- src/misc/tim/timMan.c | 20 +++++++-- 11 files changed, 122 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 51c373c8..41e38588 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -1384,6 +1384,7 @@ extern Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p ); extern int Gia_ManBoxNum( Gia_Man_t * p ); extern int Gia_ManRegBoxNum( Gia_Man_t * p ); extern int Gia_ManNonRegBoxNum( Gia_Man_t * p ); +extern int Gia_ManBlackBoxNum( Gia_Man_t * p ); extern int Gia_ManBoxCiNum( Gia_Man_t * p ); extern int Gia_ManBoxCoNum( Gia_Man_t * p ); extern int Gia_ManClockDomainNum( Gia_Man_t * p ); diff --git a/src/aig/gia/giaFadds.c b/src/aig/gia/giaFadds.c index 4a3a07ea..4b757d35 100644 --- a/src/aig/gia/giaFadds.c +++ b/src/aig/gia/giaFadds.c @@ -538,7 +538,7 @@ Tim_Man_t * Gia_ManGenerateTim( int nPis, int nPos, int nBoxes, int nIns, int nO curPo = 0; for ( i = 0; i < nBoxes; i++ ) { - Tim_ManCreateBox( pMan, curPo, nIns, curPi, nOuts, 0 ); + Tim_ManCreateBox( pMan, curPo, nIns, curPi, nOuts, 0, 0 ); curPi += nOuts; curPo += nIns; } diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c index 78c9e42f..bae40c9a 100644 --- a/src/aig/gia/giaMan.c +++ b/src/aig/gia/giaMan.c @@ -447,6 +447,8 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) Abc_Print( 1, " ch =%5d", Gia_ManChoiceNum(p) ); if ( p->pManTime ) Abc_Print( 1, " box = %d", Gia_ManNonRegBoxNum(p) ); + if ( p->pManTime ) + Abc_Print( 1, " bb = %d", Gia_ManBlackBoxNum(p) ); if ( Gia_ManBufNum(p) ) Abc_Print( 1, " buf = %d", Gia_ManBufNum(p) ); if ( pPars && pPars->fMuxXor ) diff --git a/src/aig/gia/giaMfs.c b/src/aig/gia/giaMfs.c index ca5d4038..e5dfb788 100644 --- a/src/aig/gia/giaMfs.c +++ b/src/aig/gia/giaMfs.c @@ -65,10 +65,13 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p); int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p); int i, j, k, curCi, curCo, nBoxIns, nBoxOuts; - int Id, iFan, nMfsVars, Counter = 0; + int Id, iFan, nMfsVars, nBbIns = 0, nBbOuts = 0, Counter = 0; assert( !p->pAigExtra || Gia_ManPiNum(p->pAigExtra) <= 6 ); + Tim_ManBlackBoxIoNum( pManTime, &nBbIns, &nBbOuts ); + // skip PIs due to box outputs + Counter += nBbOuts; // prepare storage - nMfsVars = Gia_ManCiNum(p) + 1 + Gia_ManLutNum(p) + Gia_ManCoNum(p); + nMfsVars = Gia_ManCiNum(p) + 1 + Gia_ManLutNum(p) + Gia_ManCoNum(p) + nBbIns + nBbOuts; vFanins = Vec_WecStart( nMfsVars ); vFixed = Vec_StrStart( nMfsVars ); vEmpty = Vec_StrStart( nMfsVars ); @@ -118,16 +121,18 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) } Gia_ObjSetCopyArray( p, Gia_ObjId(p, pObj), Counter++ ); } + // skip POs due to box inputs + Counter += nBbIns; assert( Counter == nMfsVars ); // add functions of the boxes if ( p->pAigExtra ) { + int iBbIn = 0, iBbOut = 0; Gia_ObjComputeTruthTableStart( p->pAigExtra, 6 ); curCi = nRealPis; curCo = 0; for ( k = 0; k < nBoxes; k++ ) { - assert( !Tim_ManBoxIsBlack(pManTime, k) ); nBoxIns = Tim_ManBoxInputNum( pManTime, k ); nBoxOuts = Tim_ManBoxOutputNum( pManTime, k ); // collect truth table leaves @@ -135,34 +140,62 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) for ( i = 0; i < nBoxIns; i++ ) Vec_IntPush( vLeaves, Gia_ObjId(p->pAigExtra, Gia_ManCi(p->pAigExtra, i)) ); // iterate through box outputs - //printf( "Box %d:\n", k ); - for ( j = 0; j < nBoxOuts; j++ ) + if ( !Tim_ManBoxIsBlack(pManTime, k) ) { - // CI corresponding to the box outputs - pObj = Gia_ManCi( p, curCi + j ); - Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) ); - // box output in the extra manager - pObjExtra = Gia_ManCo( p->pAigExtra, curCi - nRealPis + j ); - // compute truth table - if ( Gia_ObjFaninId0p(p->pAigExtra, pObjExtra) == 0 ) - uTruth = 0; - else if ( Gia_ObjIsCi(Gia_ObjFanin0(pObjExtra)) ) - uTruth = uTruths6[Gia_ObjCioId(Gia_ObjFanin0(pObjExtra))]; - else - uTruth = *Gia_ObjComputeTruthTableCut( p->pAigExtra, Gia_ObjFanin0(pObjExtra), vLeaves ); - uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth; - Vec_WrdWriteEntry( vTruths, Counter, uTruth ); - //Dau_DsdPrintFromTruth( &uTruth, Vec_IntSize(vLeaves) ); - // add box inputs (POs of the AIG) as fanins - vArray = Vec_WecEntry( vFanins, Counter ); - Vec_IntGrow( vArray, nBoxIns ); + for ( j = 0; j < nBoxOuts; j++ ) + { + // CI corresponding to the box outputs + pObj = Gia_ManCi( p, curCi + j ); + Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) ); + // box output in the extra manager + pObjExtra = Gia_ManCo( p->pAigExtra, curCi - nRealPis + j ); + // compute truth table + if ( Gia_ObjFaninId0p(p->pAigExtra, pObjExtra) == 0 ) + uTruth = 0; + else if ( Gia_ObjIsCi(Gia_ObjFanin0(pObjExtra)) ) + uTruth = uTruths6[Gia_ObjCioId(Gia_ObjFanin0(pObjExtra))]; + else + uTruth = *Gia_ObjComputeTruthTableCut( p->pAigExtra, Gia_ObjFanin0(pObjExtra), vLeaves ); + uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth; + Vec_WrdWriteEntry( vTruths, Counter, uTruth ); + //Dau_DsdPrintFromTruth( &uTruth, Vec_IntSize(vLeaves) ); + // add box inputs (POs of the AIG) as fanins + vArray = Vec_WecEntry( vFanins, Counter ); + Vec_IntGrow( vArray, nBoxIns ); + for ( i = 0; i < nBoxIns; i++ ) + { + iFan = Gia_ObjId( p, Gia_ManCo(p, curCo + i) ); + assert( Gia_ObjCopyArray(p, iFan) >= 0 ); + Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) ); + } + Vec_StrWriteEntry( vFixed, Counter, (char)1 ); + } + } + else // create buffers for black box inputs and outputs + { + for ( j = 0; j < nBoxOuts; j++ ) + { + // CI corresponding to the box outputs + pObj = Gia_ManCi( p, curCi + j ); + Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) ); + // connect it with the special primary input (iBbOut) + vArray = Vec_WecEntry( vFanins, Counter ); + assert( Vec_IntSize(vArray) == 0 ); + Vec_IntFill( vArray, 1, iBbOut++ ); + Vec_StrWriteEntry( vFixed, Counter, (char)1 ); + Vec_StrWriteEntry( vEmpty, Counter, (char)1 ); + Vec_WrdWriteEntry( vTruths, Counter, uTruths6[0] ); + } for ( i = 0; i < nBoxIns; i++ ) { - iFan = Gia_ObjId( p, Gia_ManCo(p, curCo + i) ); - assert( Gia_ObjCopyArray(p, iFan) >= 0 ); - Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) ); + // CO corresponding to the box inputs + pObj = Gia_ManCo( p, curCo + i ); + Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) ); + // connect it with the special primary output (iBbIn) + vArray = Vec_WecEntry( vFanins, nMfsVars - nBbIns + iBbIn++ ); + assert( Vec_IntSize(vArray) == 0 ); + Vec_IntFill( vArray, 1, Counter ); } - Vec_StrWriteEntry( vFixed, Counter, (char)1 ); } // set internal POs pointing directly to internal PIs as no-delay for ( i = 0; i < nBoxIns; i++ ) @@ -182,10 +215,12 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) assert( curCi == Gia_ManCiNum(p) ); assert( curCo == Gia_ManCoNum(p) ); assert( curCi - nRealPis == Gia_ManCoNum(p->pAigExtra) ); + assert( iBbIn == nBbIns ); + assert( iBbOut == nBbOuts ); } // finalize Vec_IntFree( vLeaves ); - return Sfm_NtkConstruct( vFanins, nRealPis, nRealPos, vFixed, vEmpty, vTruths ); + return Sfm_NtkConstruct( vFanins, nBbOuts + nRealPis, nRealPos + nBbIns, vFixed, vEmpty, vTruths ); } /**Function************************************************************* @@ -208,14 +243,19 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk ) int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p); int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p); int i, k, Id, curCi, curCo, nBoxIns, nBoxOuts, iLitNew, iMfsId, iGroup, Fanin; - int nMfsNodes = 1 + Gia_ManCiNum(p) + Gia_ManLutNum(p) + Gia_ManCoNum(p); + int nMfsNodes; word * pTruth, uTruthVar = ABC_CONST(0xAAAAAAAAAAAAAAAA); Vec_Wec_t * vGroups = Vec_WecStart( nBoxes ); - Vec_Int_t * vMfs2Gia = Vec_IntStartFull( nMfsNodes ); - Vec_Int_t * vGroupMap = Vec_IntStartFull( nMfsNodes ); + Vec_Int_t * vMfs2Gia; + Vec_Int_t * vGroupMap; Vec_Int_t * vMfsTopo, * vCover, * vBoxesLeft; Vec_Int_t * vArray, * vLeaves; Vec_Int_t * vMapping, * vMapping2; + int nBbIns = 0, nBbOuts = 0; + Tim_ManBlackBoxIoNum( pManTime, &nBbIns, &nBbOuts ); + nMfsNodes = 1 + Gia_ManCiNum(p) + Gia_ManLutNum(p) + Gia_ManCoNum(p) + nBbIns + nBbOuts; + vMfs2Gia = Vec_IntStartFull( nMfsNodes ); + vGroupMap = Vec_IntStartFull( nMfsNodes ); // collect nodes curCi = nRealPis; curCo = 0; @@ -280,6 +320,14 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk ) pTruth = Sfm_NodeReadTruth( pNtk, iMfsId ); iGroup = Vec_IntEntry( vGroupMap, iMfsId ); vArray = Sfm_NodeReadFanins( pNtk, iMfsId ); // belongs to pNtk + if ( Vec_IntSize(vArray) == 1 && Vec_IntEntry(vArray,0) < nBbOuts ) // skip unreal inputs + { + // create CI for the output of black box + assert( Abc_LitIsCompl(iGroup) ); + iLitNew = Gia_ManAppendCi( pNew ); + Vec_IntWriteEntry( vMfs2Gia, iMfsId, iLitNew ); + continue; + } Vec_IntClear( vLeaves ); Vec_IntForEachEntry( vArray, Fanin, k ) { diff --git a/src/aig/gia/giaTim.c b/src/aig/gia/giaTim.c index d48f2637..98f0ee44 100644 --- a/src/aig/gia/giaTim.c +++ b/src/aig/gia/giaTim.c @@ -58,6 +58,10 @@ int Gia_ManNonRegBoxNum( Gia_Man_t * p ) { return Gia_ManBoxNum(p) - Gia_ManRegBoxNum(p); } +int Gia_ManBlackBoxNum( Gia_Man_t * p ) +{ + return Tim_ManBlackBoxNum((Tim_Man_t *)p->pManTime); +} int Gia_ManBoxCiNum( Gia_Man_t * p ) { return p->pManTime ? Gia_ManCiNum(p) - Tim_ManPiNum((Tim_Man_t *)p->pManTime) : 0; @@ -751,7 +755,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime; Gia_Man_t * pNew, * pTemp; Gia_Obj_t * pObj, * pObjBox; - int i, k, curCi, curCo; + int i, k, curCi, curCo, nBBins = 0, nBBouts = 0; assert( !fSeq || p->vRegClasses ); //assert( Gia_ManRegNum(p) == 0 ); assert( Gia_ManCiNum(p) == Tim_ManPiNum(pManTime) + Gia_ManCoNum(pBoxes) ); @@ -782,6 +786,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v Gia_ObjSetTravIdCurrent( pBoxes, Gia_ManConst0(pBoxes) ); Gia_ManConst0(pBoxes)->Value = 0; // add internal nodes + //printf( "%d ", Tim_ManBoxIsBlack(pManTime, i) ); if ( Tim_ManBoxIsBlack(pManTime, i) ) { int fSkip = (vBoxPres != NULL && !Vec_IntEntry(vBoxPres, i)); @@ -790,12 +795,14 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v pObj = Gia_ManCo( p, curCo + k ); Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew ); pObj->Value = fSkip ? -1 : Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + nBBouts++; } for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ ) { pObj = Gia_ManCi( p, curCi + k ); pObj->Value = fSkip ? 0 : Gia_ManAppendCi(pNew); Gia_ObjSetTravIdCurrent( p, pObj ); + nBBins++; } } else @@ -824,6 +831,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v curCo += Tim_ManBoxInputNum(pManTime, i); curCi += Tim_ManBoxOutputNum(pManTime, i); } + //printf( "\n" ); // add remaining nodes for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ ) { @@ -840,10 +848,10 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v pNew = Gia_ManCleanup( pTemp = pNew ); Gia_ManCleanupRemap( p, pTemp ); Gia_ManStop( pTemp ); - assert( Tim_ManPoNum(pManTime) == Gia_ManCoNum(pNew) ); - assert( Tim_ManPiNum(pManTime) == Gia_ManCiNum(pNew) ); + assert( Tim_ManPoNum(pManTime) == Gia_ManCoNum(pNew) - nBBouts ); + assert( Tim_ManPiNum(pManTime) == Gia_ManCiNum(pNew) - nBBins ); // implement initial state if given - if ( p->vRegInits && Vec_IntSum(p->vRegInits) ) + if ( fSeq && p->vRegInits && Vec_IntSum(p->vRegInits) ) { char * pInit = ABC_ALLOC( char, Vec_IntSize(p->vRegInits) + 1 ); Gia_Obj_t * pObj; diff --git a/src/base/abci/abcTim.c b/src/base/abci/abcTim.c index 98d3220a..ba183402 100644 --- a/src/base/abci/abcTim.c +++ b/src/base/abci/abcTim.c @@ -327,7 +327,7 @@ Gia_Man_t * Abc_NtkTestTimDeriveGia( Abc_Ntk_t * pNtk, int fVerbose ) } // create box BoxUniqueId = Abc_ObjFaninNum(pObj); // in this case, the node size is the ID of its delay table - Tim_ManCreateBox( pTim, curPo, Abc_ObjFaninNum(pObj), curPi, 1, BoxUniqueId ); + Tim_ManCreateBox( pTim, curPo, Abc_ObjFaninNum(pObj), curPi, 1, BoxUniqueId, 0 ); curPo += Abc_ObjFaninNum(pObj); // handle box inputs diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index 757a8005..c5a6ab2f 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -613,7 +613,7 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds ) pObj->Mark = 0; // create new box - Tim_ManCreateBox( pManTime, curPo, nRange0 + nRange1, curPi, nRange, -1 ); + Tim_ManCreateBox( pManTime, curPo, nRange0 + nRange1, curPi, nRange, -1, 0 ); curPi += nRange; curPo += nRange0 + nRange1; diff --git a/src/misc/tim/tim.h b/src/misc/tim/tim.h index 04ef6706..266688dd 100644 --- a/src/misc/tim/tim.h +++ b/src/misc/tim/tim.h @@ -110,7 +110,7 @@ typedef struct Tim_Man_t_ Tim_Man_t; //////////////////////////////////////////////////////////////////////// /*=== timBox.c ===========================================================*/ -extern void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable ); +extern void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable, int fBlack ); extern int Tim_ManBoxForCi( Tim_Man_t * p, int iCo ); extern int Tim_ManBoxForCo( Tim_Man_t * p, int iCi ); extern int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox ); @@ -147,6 +147,7 @@ extern int Tim_ManPiNum( Tim_Man_t * p ); extern int Tim_ManPoNum( Tim_Man_t * p ); extern int Tim_ManBoxNum( Tim_Man_t * p ); extern int Tim_ManBlackBoxNum( Tim_Man_t * p ); +extern void Tim_ManBlackBoxIoNum( Tim_Man_t * p, int * pnBbIns, int * pnBbOuts ); extern int Tim_ManDelayTableNum( Tim_Man_t * p ); extern void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables ); extern void Tim_ManTravIdDisable( Tim_Man_t * p ); diff --git a/src/misc/tim/timBox.c b/src/misc/tim/timBox.c index a1526673..9e311428 100644 --- a/src/misc/tim/timBox.c +++ b/src/misc/tim/timBox.c @@ -41,7 +41,7 @@ ABC_NAMESPACE_IMPL_START SeeAlso [] ***********************************************************************/ -void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable ) +void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable, int fBlack ) { Tim_Box_t * pBox; int i; @@ -54,6 +54,7 @@ void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int n pBox->iDelayTable = iDelayTable; pBox->nInputs = nIns; pBox->nOutputs = nOuts; + pBox->fBlack = fBlack; for ( i = 0; i < nIns; i++ ) { assert( firstIn+i < p->nCos ); diff --git a/src/misc/tim/timDump.c b/src/misc/tim/timDump.c index 1cda07b9..73519fd3 100644 --- a/src/misc/tim/timDump.c +++ b/src/misc/tim/timDump.c @@ -70,6 +70,7 @@ Vec_Str_t * Tim_ManSave( Tim_Man_t * p, int fHieOnly ) Vec_StrPutI_ne( vStr, Tim_ManBoxOutputNum(p, pBox->iBox) ); Vec_StrPutI_ne( vStr, Tim_ManBoxDelayTableId(p, pBox->iBox) ); // can be -1 if delay table is not given Vec_StrPutI_ne( vStr, Tim_ManBoxCopy(p, pBox->iBox) ); // can be -1 if the copy is node defined + //Vec_StrPutI_ne( vStr, Tim_ManBoxIsBlack(p, pBox->iBox) ); } if ( fHieOnly ) return vStr; @@ -114,7 +115,7 @@ Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly ) Tim_Man_t * pMan; Tim_Obj_t * pObj; int VerNum, nCis, nCos, nPis, nPos; - int nBoxes, nBoxIns, nBoxOuts, CopyBox; + int nBoxes, nBoxIns, nBoxOuts, CopyBox, fBlack; int TableId, nTables, TableSize, TableX, TableY; int i, k, curPi, curPo, iStr = 0; float * pDelayTable; @@ -143,7 +144,8 @@ Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly ) nBoxOuts = Vec_StrGetI_ne( p, &iStr ); TableId = Vec_StrGetI_ne( p, &iStr ); CopyBox = Vec_StrGetI_ne( p, &iStr ); - Tim_ManCreateBox( pMan, curPo, nBoxIns, curPi, nBoxOuts, TableId ); + fBlack = 0;//Vec_StrGetI_ne( p, &iStr ); + Tim_ManCreateBox( pMan, curPo, nBoxIns, curPi, nBoxOuts, TableId, fBlack ); Tim_ManBoxSetCopy( pMan, i, CopyBox ); curPi += nBoxOuts; curPo += nBoxIns; diff --git a/src/misc/tim/timMan.c b/src/misc/tim/timMan.c index 87e7e0f3..8cec9788 100644 --- a/src/misc/tim/timMan.c +++ b/src/misc/tim/timMan.c @@ -145,7 +145,7 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fUnitDelay ) Tim_ManForEachBox( p, pBox, i ) { Tim_ManCreateBox( pNew, pBox->Inouts[0], pBox->nInputs, - pBox->Inouts[pBox->nInputs], pBox->nOutputs, pBox->iDelayTable ); + pBox->Inouts[pBox->nInputs], pBox->nOutputs, pBox->iDelayTable, pBox->fBlack ); Tim_ManBoxSetCopy( pNew, i, pBox->iCopy ); } } @@ -228,7 +228,7 @@ Tim_Man_t * Tim_ManTrim( Tim_Man_t * p, Vec_Int_t * vBoxPres ) Tim_ManForEachBox( p, pBox, i ) if ( Vec_IntEntry(vBoxPres, i) ) { - Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable ); + Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable, pBox->fBlack ); Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, Tim_ManBoxCopy(p, i) == -1 ? i : Tim_ManBoxCopy(p, i) ); curPi += pBox->nOutputs; curPo += pBox->nInputs; @@ -321,7 +321,7 @@ Tim_Man_t * Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff Vec_IntForEachEntry( vBoxesLeft, iBox, i ) { pBox = Tim_ManBox( p, iBox ); - Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable ); + Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable, pBox->fBlack ); Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, Tim_ManBoxCopy(p, iBox) == -1 ? iBox : Tim_ManBoxCopy(p, iBox) ); curPi += pBox->nOutputs; curPo += pBox->nInputs; @@ -730,6 +730,20 @@ int Tim_ManBlackBoxNum( Tim_Man_t * p ) Counter += pBox->fBlack; return Counter; } +void Tim_ManBlackBoxIoNum( Tim_Man_t * p, int * pnBbIns, int * pnBbOuts ) +{ + Tim_Box_t * pBox; + int i; + *pnBbIns = *pnBbOuts = 0; + if ( Tim_ManBoxNum(p) ) + Tim_ManForEachBox( p, pBox, i ) + { + if ( !pBox->fBlack ) + continue; + *pnBbIns += Tim_ManBoxInputNum( p, i ); + *pnBbOuts += Tim_ManBoxOutputNum( p, i ); + } +} int Tim_ManDelayTableNum( Tim_Man_t * p ) { return p->vDelayTables ? Vec_PtrSize(p->vDelayTables) : 0; -- cgit v1.2.3