Commit a1e9f668 by Alan Mishchenko

Adding support for black boxes in extended AIG.

parent 26dc25b7
...@@ -1384,6 +1384,7 @@ extern Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p ); ...@@ -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_ManBoxNum( Gia_Man_t * p );
extern int Gia_ManRegBoxNum( Gia_Man_t * p ); extern int Gia_ManRegBoxNum( Gia_Man_t * p );
extern int Gia_ManNonRegBoxNum( 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_ManBoxCiNum( Gia_Man_t * p );
extern int Gia_ManBoxCoNum( Gia_Man_t * p ); extern int Gia_ManBoxCoNum( Gia_Man_t * p );
extern int Gia_ManClockDomainNum( Gia_Man_t * p ); extern int Gia_ManClockDomainNum( Gia_Man_t * p );
......
...@@ -538,7 +538,7 @@ Tim_Man_t * Gia_ManGenerateTim( int nPis, int nPos, int nBoxes, int nIns, int nO ...@@ -538,7 +538,7 @@ Tim_Man_t * Gia_ManGenerateTim( int nPis, int nPos, int nBoxes, int nIns, int nO
curPo = 0; curPo = 0;
for ( i = 0; i < nBoxes; i++ ) 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; curPi += nOuts;
curPo += nIns; curPo += nIns;
} }
......
...@@ -447,6 +447,8 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) ...@@ -447,6 +447,8 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
Abc_Print( 1, " ch =%5d", Gia_ManChoiceNum(p) ); Abc_Print( 1, " ch =%5d", Gia_ManChoiceNum(p) );
if ( p->pManTime ) if ( p->pManTime )
Abc_Print( 1, " box = %d", Gia_ManNonRegBoxNum(p) ); Abc_Print( 1, " box = %d", Gia_ManNonRegBoxNum(p) );
if ( p->pManTime )
Abc_Print( 1, " bb = %d", Gia_ManBlackBoxNum(p) );
if ( Gia_ManBufNum(p) ) if ( Gia_ManBufNum(p) )
Abc_Print( 1, " buf = %d", Gia_ManBufNum(p) ); Abc_Print( 1, " buf = %d", Gia_ManBufNum(p) );
if ( pPars && pPars->fMuxXor ) if ( pPars && pPars->fMuxXor )
......
...@@ -65,10 +65,13 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) ...@@ -65,10 +65,13 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p )
int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p); int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p);
int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p); int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p);
int i, j, k, curCi, curCo, nBoxIns, nBoxOuts; 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 ); assert( !p->pAigExtra || Gia_ManPiNum(p->pAigExtra) <= 6 );
Tim_ManBlackBoxIoNum( pManTime, &nBbIns, &nBbOuts );
// skip PIs due to box outputs
Counter += nBbOuts;
// prepare storage // 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 ); vFanins = Vec_WecStart( nMfsVars );
vFixed = Vec_StrStart( nMfsVars ); vFixed = Vec_StrStart( nMfsVars );
vEmpty = Vec_StrStart( nMfsVars ); vEmpty = Vec_StrStart( nMfsVars );
...@@ -118,16 +121,18 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) ...@@ -118,16 +121,18 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p )
} }
Gia_ObjSetCopyArray( p, Gia_ObjId(p, pObj), Counter++ ); Gia_ObjSetCopyArray( p, Gia_ObjId(p, pObj), Counter++ );
} }
// skip POs due to box inputs
Counter += nBbIns;
assert( Counter == nMfsVars ); assert( Counter == nMfsVars );
// add functions of the boxes // add functions of the boxes
if ( p->pAigExtra ) if ( p->pAigExtra )
{ {
int iBbIn = 0, iBbOut = 0;
Gia_ObjComputeTruthTableStart( p->pAigExtra, 6 ); Gia_ObjComputeTruthTableStart( p->pAigExtra, 6 );
curCi = nRealPis; curCi = nRealPis;
curCo = 0; curCo = 0;
for ( k = 0; k < nBoxes; k++ ) for ( k = 0; k < nBoxes; k++ )
{ {
assert( !Tim_ManBoxIsBlack(pManTime, k) );
nBoxIns = Tim_ManBoxInputNum( pManTime, k ); nBoxIns = Tim_ManBoxInputNum( pManTime, k );
nBoxOuts = Tim_ManBoxOutputNum( pManTime, k ); nBoxOuts = Tim_ManBoxOutputNum( pManTime, k );
// collect truth table leaves // collect truth table leaves
...@@ -135,34 +140,62 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) ...@@ -135,34 +140,62 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p )
for ( i = 0; i < nBoxIns; i++ ) for ( i = 0; i < nBoxIns; i++ )
Vec_IntPush( vLeaves, Gia_ObjId(p->pAigExtra, Gia_ManCi(p->pAigExtra, i)) ); Vec_IntPush( vLeaves, Gia_ObjId(p->pAigExtra, Gia_ManCi(p->pAigExtra, i)) );
// iterate through box outputs // iterate through box outputs
//printf( "Box %d:\n", k ); if ( !Tim_ManBoxIsBlack(pManTime, k) )
for ( j = 0; j < nBoxOuts; j++ )
{ {
// CI corresponding to the box outputs for ( j = 0; j < nBoxOuts; j++ )
pObj = Gia_ManCi( p, curCi + j ); {
Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) ); // CI corresponding to the box outputs
// box output in the extra manager pObj = Gia_ManCi( p, curCi + j );
pObjExtra = Gia_ManCo( p->pAigExtra, curCi - nRealPis + j ); Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
// compute truth table // box output in the extra manager
if ( Gia_ObjFaninId0p(p->pAigExtra, pObjExtra) == 0 ) pObjExtra = Gia_ManCo( p->pAigExtra, curCi - nRealPis + j );
uTruth = 0; // compute truth table
else if ( Gia_ObjIsCi(Gia_ObjFanin0(pObjExtra)) ) if ( Gia_ObjFaninId0p(p->pAigExtra, pObjExtra) == 0 )
uTruth = uTruths6[Gia_ObjCioId(Gia_ObjFanin0(pObjExtra))]; uTruth = 0;
else else if ( Gia_ObjIsCi(Gia_ObjFanin0(pObjExtra)) )
uTruth = *Gia_ObjComputeTruthTableCut( p->pAigExtra, Gia_ObjFanin0(pObjExtra), vLeaves ); uTruth = uTruths6[Gia_ObjCioId(Gia_ObjFanin0(pObjExtra))];
uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth; else
Vec_WrdWriteEntry( vTruths, Counter, uTruth ); uTruth = *Gia_ObjComputeTruthTableCut( p->pAigExtra, Gia_ObjFanin0(pObjExtra), vLeaves );
//Dau_DsdPrintFromTruth( &uTruth, Vec_IntSize(vLeaves) ); uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth;
// add box inputs (POs of the AIG) as fanins Vec_WrdWriteEntry( vTruths, Counter, uTruth );
vArray = Vec_WecEntry( vFanins, Counter ); //Dau_DsdPrintFromTruth( &uTruth, Vec_IntSize(vLeaves) );
Vec_IntGrow( vArray, nBoxIns ); // 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++ ) for ( i = 0; i < nBoxIns; i++ )
{ {
iFan = Gia_ObjId( p, Gia_ManCo(p, curCo + i) ); // CO corresponding to the box inputs
assert( Gia_ObjCopyArray(p, iFan) >= 0 ); pObj = Gia_ManCo( p, curCo + i );
Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) ); 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 // set internal POs pointing directly to internal PIs as no-delay
for ( i = 0; i < nBoxIns; i++ ) for ( i = 0; i < nBoxIns; i++ )
...@@ -182,10 +215,12 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p ) ...@@ -182,10 +215,12 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p )
assert( curCi == Gia_ManCiNum(p) ); assert( curCi == Gia_ManCiNum(p) );
assert( curCo == Gia_ManCoNum(p) ); assert( curCo == Gia_ManCoNum(p) );
assert( curCi - nRealPis == Gia_ManCoNum(p->pAigExtra) ); assert( curCi - nRealPis == Gia_ManCoNum(p->pAigExtra) );
assert( iBbIn == nBbIns );
assert( iBbOut == nBbOuts );
} }
// finalize // finalize
Vec_IntFree( vLeaves ); Vec_IntFree( vLeaves );
return Sfm_NtkConstruct( vFanins, nRealPis, nRealPos, vFixed, vEmpty, vTruths ); return Sfm_NtkConstruct( vFanins, nBbOuts + nRealPis, nRealPos + nBbIns, vFixed, vEmpty, vTruths );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -208,14 +243,19 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk ) ...@@ -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 nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p);
int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p); int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p);
int i, k, Id, curCi, curCo, nBoxIns, nBoxOuts, iLitNew, iMfsId, iGroup, Fanin; 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); word * pTruth, uTruthVar = ABC_CONST(0xAAAAAAAAAAAAAAAA);
Vec_Wec_t * vGroups = Vec_WecStart( nBoxes ); Vec_Wec_t * vGroups = Vec_WecStart( nBoxes );
Vec_Int_t * vMfs2Gia = Vec_IntStartFull( nMfsNodes ); Vec_Int_t * vMfs2Gia;
Vec_Int_t * vGroupMap = Vec_IntStartFull( nMfsNodes ); Vec_Int_t * vGroupMap;
Vec_Int_t * vMfsTopo, * vCover, * vBoxesLeft; Vec_Int_t * vMfsTopo, * vCover, * vBoxesLeft;
Vec_Int_t * vArray, * vLeaves; Vec_Int_t * vArray, * vLeaves;
Vec_Int_t * vMapping, * vMapping2; 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 // collect nodes
curCi = nRealPis; curCi = nRealPis;
curCo = 0; curCo = 0;
...@@ -280,6 +320,14 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk ) ...@@ -280,6 +320,14 @@ Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk )
pTruth = Sfm_NodeReadTruth( pNtk, iMfsId ); pTruth = Sfm_NodeReadTruth( pNtk, iMfsId );
iGroup = Vec_IntEntry( vGroupMap, iMfsId ); iGroup = Vec_IntEntry( vGroupMap, iMfsId );
vArray = Sfm_NodeReadFanins( pNtk, iMfsId ); // belongs to pNtk 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_IntClear( vLeaves );
Vec_IntForEachEntry( vArray, Fanin, k ) Vec_IntForEachEntry( vArray, Fanin, k )
{ {
......
...@@ -58,6 +58,10 @@ int Gia_ManNonRegBoxNum( Gia_Man_t * p ) ...@@ -58,6 +58,10 @@ int Gia_ManNonRegBoxNum( Gia_Man_t * p )
{ {
return Gia_ManBoxNum(p) - Gia_ManRegBoxNum(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 ) int Gia_ManBoxCiNum( Gia_Man_t * p )
{ {
return p->pManTime ? Gia_ManCiNum(p) - Tim_ManPiNum((Tim_Man_t *)p->pManTime) : 0; 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 ...@@ -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; Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
Gia_Man_t * pNew, * pTemp; Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pObjBox; Gia_Obj_t * pObj, * pObjBox;
int i, k, curCi, curCo; int i, k, curCi, curCo, nBBins = 0, nBBouts = 0;
assert( !fSeq || p->vRegClasses ); assert( !fSeq || p->vRegClasses );
//assert( Gia_ManRegNum(p) == 0 ); //assert( Gia_ManRegNum(p) == 0 );
assert( Gia_ManCiNum(p) == Tim_ManPiNum(pManTime) + Gia_ManCoNum(pBoxes) ); 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 ...@@ -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_ObjSetTravIdCurrent( pBoxes, Gia_ManConst0(pBoxes) );
Gia_ManConst0(pBoxes)->Value = 0; Gia_ManConst0(pBoxes)->Value = 0;
// add internal nodes // add internal nodes
//printf( "%d ", Tim_ManBoxIsBlack(pManTime, i) );
if ( Tim_ManBoxIsBlack(pManTime, i) ) if ( Tim_ManBoxIsBlack(pManTime, i) )
{ {
int fSkip = (vBoxPres != NULL && !Vec_IntEntry(vBoxPres, 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 ...@@ -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 ); pObj = Gia_ManCo( p, curCo + k );
Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew ); Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
pObj->Value = fSkip ? -1 : Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); pObj->Value = fSkip ? -1 : Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
nBBouts++;
} }
for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ ) for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
{ {
pObj = Gia_ManCi( p, curCi + k ); pObj = Gia_ManCi( p, curCi + k );
pObj->Value = fSkip ? 0 : Gia_ManAppendCi(pNew); pObj->Value = fSkip ? 0 : Gia_ManAppendCi(pNew);
Gia_ObjSetTravIdCurrent( p, pObj ); Gia_ObjSetTravIdCurrent( p, pObj );
nBBins++;
} }
} }
else else
...@@ -824,6 +831,7 @@ Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * v ...@@ -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); curCo += Tim_ManBoxInputNum(pManTime, i);
curCi += Tim_ManBoxOutputNum(pManTime, i); curCi += Tim_ManBoxOutputNum(pManTime, i);
} }
//printf( "\n" );
// add remaining nodes // add remaining nodes
for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ ) 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 ...@@ -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 ); pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManCleanupRemap( p, pTemp ); Gia_ManCleanupRemap( p, pTemp );
Gia_ManStop( pTemp ); Gia_ManStop( pTemp );
assert( Tim_ManPoNum(pManTime) == Gia_ManCoNum(pNew) ); assert( Tim_ManPoNum(pManTime) == Gia_ManCoNum(pNew) - nBBouts );
assert( Tim_ManPiNum(pManTime) == Gia_ManCiNum(pNew) ); assert( Tim_ManPiNum(pManTime) == Gia_ManCiNum(pNew) - nBBins );
// implement initial state if given // 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 ); char * pInit = ABC_ALLOC( char, Vec_IntSize(p->vRegInits) + 1 );
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
......
...@@ -327,7 +327,7 @@ Gia_Man_t * Abc_NtkTestTimDeriveGia( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -327,7 +327,7 @@ Gia_Man_t * Abc_NtkTestTimDeriveGia( Abc_Ntk_t * pNtk, int fVerbose )
} }
// create box // create box
BoxUniqueId = Abc_ObjFaninNum(pObj); // in this case, the node size is the ID of its delay table 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); curPo += Abc_ObjFaninNum(pObj);
// handle box inputs // handle box inputs
......
...@@ -613,7 +613,7 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds ) ...@@ -613,7 +613,7 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds )
pObj->Mark = 0; pObj->Mark = 0;
// create new box // create new box
Tim_ManCreateBox( pManTime, curPo, nRange0 + nRange1, curPi, nRange, -1 ); Tim_ManCreateBox( pManTime, curPo, nRange0 + nRange1, curPi, nRange, -1, 0 );
curPi += nRange; curPi += nRange;
curPo += nRange0 + nRange1; curPo += nRange0 + nRange1;
......
...@@ -110,7 +110,7 @@ typedef struct Tim_Man_t_ Tim_Man_t; ...@@ -110,7 +110,7 @@ typedef struct Tim_Man_t_ Tim_Man_t;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/*=== timBox.c ===========================================================*/ /*=== 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_ManBoxForCi( Tim_Man_t * p, int iCo );
extern int Tim_ManBoxForCo( Tim_Man_t * p, int iCi ); extern int Tim_ManBoxForCo( Tim_Man_t * p, int iCi );
extern int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox ); extern int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox );
...@@ -147,6 +147,7 @@ extern int Tim_ManPiNum( Tim_Man_t * p ); ...@@ -147,6 +147,7 @@ extern int Tim_ManPiNum( Tim_Man_t * p );
extern int Tim_ManPoNum( Tim_Man_t * p ); extern int Tim_ManPoNum( Tim_Man_t * p );
extern int Tim_ManBoxNum( Tim_Man_t * p ); extern int Tim_ManBoxNum( Tim_Man_t * p );
extern int Tim_ManBlackBoxNum( 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 int Tim_ManDelayTableNum( Tim_Man_t * p );
extern void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables ); extern void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables );
extern void Tim_ManTravIdDisable( Tim_Man_t * p ); extern void Tim_ManTravIdDisable( Tim_Man_t * p );
......
...@@ -41,7 +41,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -41,7 +41,7 @@ ABC_NAMESPACE_IMPL_START
SeeAlso [] 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; Tim_Box_t * pBox;
int i; int i;
...@@ -54,6 +54,7 @@ void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int n ...@@ -54,6 +54,7 @@ void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int n
pBox->iDelayTable = iDelayTable; pBox->iDelayTable = iDelayTable;
pBox->nInputs = nIns; pBox->nInputs = nIns;
pBox->nOutputs = nOuts; pBox->nOutputs = nOuts;
pBox->fBlack = fBlack;
for ( i = 0; i < nIns; i++ ) for ( i = 0; i < nIns; i++ )
{ {
assert( firstIn+i < p->nCos ); assert( firstIn+i < p->nCos );
......
...@@ -70,6 +70,7 @@ Vec_Str_t * Tim_ManSave( Tim_Man_t * p, int fHieOnly ) ...@@ -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_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_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_ManBoxCopy(p, pBox->iBox) ); // can be -1 if the copy is node defined
//Vec_StrPutI_ne( vStr, Tim_ManBoxIsBlack(p, pBox->iBox) );
} }
if ( fHieOnly ) if ( fHieOnly )
return vStr; return vStr;
...@@ -114,7 +115,7 @@ Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly ) ...@@ -114,7 +115,7 @@ Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly )
Tim_Man_t * pMan; Tim_Man_t * pMan;
Tim_Obj_t * pObj; Tim_Obj_t * pObj;
int VerNum, nCis, nCos, nPis, nPos; int VerNum, nCis, nCos, nPis, nPos;
int nBoxes, nBoxIns, nBoxOuts, CopyBox; int nBoxes, nBoxIns, nBoxOuts, CopyBox, fBlack;
int TableId, nTables, TableSize, TableX, TableY; int TableId, nTables, TableSize, TableX, TableY;
int i, k, curPi, curPo, iStr = 0; int i, k, curPi, curPo, iStr = 0;
float * pDelayTable; float * pDelayTable;
...@@ -143,7 +144,8 @@ Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly ) ...@@ -143,7 +144,8 @@ Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly )
nBoxOuts = Vec_StrGetI_ne( p, &iStr ); nBoxOuts = Vec_StrGetI_ne( p, &iStr );
TableId = Vec_StrGetI_ne( p, &iStr ); TableId = Vec_StrGetI_ne( p, &iStr );
CopyBox = 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 ); Tim_ManBoxSetCopy( pMan, i, CopyBox );
curPi += nBoxOuts; curPi += nBoxOuts;
curPo += nBoxIns; curPo += nBoxIns;
......
...@@ -145,7 +145,7 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fUnitDelay ) ...@@ -145,7 +145,7 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fUnitDelay )
Tim_ManForEachBox( p, pBox, i ) Tim_ManForEachBox( p, pBox, i )
{ {
Tim_ManCreateBox( pNew, pBox->Inouts[0], pBox->nInputs, 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 ); Tim_ManBoxSetCopy( pNew, i, pBox->iCopy );
} }
} }
...@@ -228,7 +228,7 @@ Tim_Man_t * Tim_ManTrim( Tim_Man_t * p, Vec_Int_t * vBoxPres ) ...@@ -228,7 +228,7 @@ Tim_Man_t * Tim_ManTrim( Tim_Man_t * p, Vec_Int_t * vBoxPres )
Tim_ManForEachBox( p, pBox, i ) Tim_ManForEachBox( p, pBox, i )
if ( Vec_IntEntry(vBoxPres, 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) ); Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, Tim_ManBoxCopy(p, i) == -1 ? i : Tim_ManBoxCopy(p, i) );
curPi += pBox->nOutputs; curPi += pBox->nOutputs;
curPo += pBox->nInputs; curPo += pBox->nInputs;
...@@ -321,7 +321,7 @@ Tim_Man_t * Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff ...@@ -321,7 +321,7 @@ Tim_Man_t * Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff
Vec_IntForEachEntry( vBoxesLeft, iBox, i ) Vec_IntForEachEntry( vBoxesLeft, iBox, i )
{ {
pBox = Tim_ManBox( p, iBox ); 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) ); Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, Tim_ManBoxCopy(p, iBox) == -1 ? iBox : Tim_ManBoxCopy(p, iBox) );
curPi += pBox->nOutputs; curPi += pBox->nOutputs;
curPo += pBox->nInputs; curPo += pBox->nInputs;
...@@ -730,6 +730,20 @@ int Tim_ManBlackBoxNum( Tim_Man_t * p ) ...@@ -730,6 +730,20 @@ int Tim_ManBlackBoxNum( Tim_Man_t * p )
Counter += pBox->fBlack; Counter += pBox->fBlack;
return Counter; 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 ) int Tim_ManDelayTableNum( Tim_Man_t * p )
{ {
return p->vDelayTables ? Vec_PtrSize(p->vDelayTables) : 0; return p->vDelayTables ? Vec_PtrSize(p->vDelayTables) : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment