Commit 735bca16 by Alan Mishchenko

Version abc60824

parent 7b09d2d2
...@@ -322,14 +322,6 @@ SOURCE=.\src\base\abci\abcUnreach.c ...@@ -322,14 +322,6 @@ SOURCE=.\src\base\abci\abcUnreach.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\abci\abcVanEijk.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcVanImp.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcVerify.c SOURCE=.\src\base\abci\abcVerify.c
# End Source File # End Source File
# End Group # End Group
...@@ -482,10 +474,6 @@ SOURCE=.\src\base\io\ioReadPla.c ...@@ -482,10 +474,6 @@ SOURCE=.\src\base\io\ioReadPla.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\io\ioReadVerilog.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioUtil.c SOURCE=.\src\base\io\ioUtil.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -99,6 +99,6 @@ alias src_rws "st; rw -l; rs -K 6 -N 2 -l; rwz -l; rs -K 9 -N 2 -l; rwz -l; ...@@ -99,6 +99,6 @@ alias src_rws "st; rw -l; rs -K 6 -N 2 -l; rwz -l; rs -K 9 -N 2 -l; rwz -l;
alias compress2rs "b -l; rs -K 6 -l; rw -l; rs -K 6 -N 2 -l; rf -l; rs -K 8 -l; b -l; rs -K 8 -N 2 -l; rw -l; rs -K 10 -l; rwz -l; rs -K 10 -N 2 -l; b -l; rs -K 12 -l; rfz -l; rs -K 12 -N 2 -l; rwz -l; b -l" alias compress2rs "b -l; rs -K 6 -l; rw -l; rs -K 6 -N 2 -l; rf -l; rs -K 8 -l; b -l; rs -K 8 -N 2 -l; rw -l; rs -K 10 -l; rwz -l; rs -K 10 -N 2 -l; b -l; rs -K 12 -l; rfz -l; rs -K 12 -N 2 -l; rwz -l; b -l"
# temporaries # temporaries
alias test "rvl th/lib.v; rvv th/t1.v" alias test "rvl th/lib.v; rvv th/t2.v"
...@@ -137,7 +137,7 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig ) ...@@ -137,7 +137,7 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig )
pMan->vStackReplaceNew = Vec_PtrAlloc( 100 ); pMan->vStackReplaceNew = Vec_PtrAlloc( 100 );
// create the constant node // create the constant node
assert( pNtkAig->vObjs->nSize == 0 ); assert( pNtkAig->vObjs->nSize == 0 );
pMan->pConst1 = Abc_NtkObjAdd( pNtkAig, ABC_OBJ_NODE ); pMan->pConst1 = Abc_NtkCreateObj( pNtkAig, ABC_OBJ_NODE );
pMan->pConst1->Type = ABC_OBJ_CONST1; pMan->pConst1->Type = ABC_OBJ_CONST1;
pNtkAig->nObjCounts[ABC_OBJ_NODE]--; pNtkAig->nObjCounts[ABC_OBJ_NODE]--;
// save the current network // save the current network
...@@ -1329,16 +1329,16 @@ void Abc_AigSetNodePhases( Abc_Ntk_t * pNtk ) ...@@ -1329,16 +1329,16 @@ void Abc_AigSetNodePhases( Abc_Ntk_t * pNtk )
int i; int i;
assert( Abc_NtkIsDfsOrdered(pNtk) ); assert( Abc_NtkIsDfsOrdered(pNtk) );
Abc_AigConst1(pNtk)->fPhase = 1; Abc_AigConst1(pNtk)->fPhase = 1;
// Abc_NtkForEachCi( pNtk, pObj, i )
// pObj->fPhase = 0;
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
pObj->fPhase = 0; pObj->fPhase = 0;
Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_NtkForEachLatchOutput( pNtk, pObj, i )
pObj->fPhase = Abc_LatchIsInit1(pObj); pObj->fPhase = Abc_LatchIsInit1(pObj);
Abc_AigForEachAnd( pNtk, pObj, i ) Abc_AigForEachAnd( pNtk, pObj, i )
pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj)) & (Abc_ObjFanin1(pObj)->fPhase ^ Abc_ObjFaninC1(pObj)); pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj)) & (Abc_ObjFanin1(pObj)->fPhase ^ Abc_ObjFaninC1(pObj));
Abc_NtkForEachPo( pNtk, pObj, i ) Abc_NtkForEachPo( pNtk, pObj, i )
pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj)); pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj));
Abc_NtkForEachLatchInput( pNtk, pObj, i )
pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj));
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -111,23 +111,23 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk ) ...@@ -111,23 +111,23 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
return 0; return 0;
} }
} }
/*
// check CI/CO numbers // check CI/CO numbers
if ( Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCiNum(pNtk) ) if ( Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCiNum(pNtk) )
{ {
fprintf( stdout, "NetworkCheck: Number of CIs does not match number of PIs and latches.\n" ); fprintf( stdout, "NetworkCheck: Number of CIs does not match number of PIs and latches.\n" );
fprintf( stdout, "One possible reason is that latches are added twice:\n" ); fprintf( stdout, "One possible reason is that latches are added twice:\n" );
fprintf( stdout, "in procedure Abc_NtkObjAdd() and in the user's code.\n" ); fprintf( stdout, "in procedure Abc_NtkCreateObj() and in the user's code.\n" );
return 0; return 0;
} }
if ( Abc_NtkPoNum(pNtk) + Abc_NtkAssertNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) ) if ( Abc_NtkPoNum(pNtk) + Abc_NtkAssertNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) )
{ {
fprintf( stdout, "NetworkCheck: Number of COs does not match number of POs, asserts, and latches.\n" ); fprintf( stdout, "NetworkCheck: Number of COs does not match number of POs, asserts, and latches.\n" );
fprintf( stdout, "One possible reason is that latches are added twice:\n" ); fprintf( stdout, "One possible reason is that latches are added twice:\n" );
fprintf( stdout, "in procedure Abc_NtkObjAdd() and in the user's code.\n" ); fprintf( stdout, "in procedure Abc_NtkCreateObj() and in the user's code.\n" );
return 0; return 0;
} }
*/
// check the names // check the names
if ( !Abc_NtkCheckNames( pNtk ) ) if ( !Abc_NtkCheckNames( pNtk ) )
return 0; return 0;
...@@ -241,36 +241,36 @@ bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk ) ...@@ -241,36 +241,36 @@ bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk )
char * pName; char * pName;
int i, NameId; int i, NameId;
// check that each CI/CO has a name if ( Abc_NtkIsNetlist(pNtk) )
Abc_NtkForEachCi( pNtk, pObj, i )
{ {
pObj = Abc_ObjFanout0Ntk(pObj); // check that each net has a name
if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL ) Abc_NtkForEachNet( pNtk, pObj, i )
{ {
fprintf( stdout, "NetworkCheck: CI with ID %d is in the network but not in the name table.\n", pObj->Id ); if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
return 0; {
fprintf( stdout, "NetworkCheck: Net \"%s\" has different name in the name table and at the data pointer.\n", pObj->pData );
return 0;
}
} }
} }
Abc_NtkForEachCo( pNtk, pObj, i ) else
{ {
if ( Abc_ObjIsLatch(pObj) ) // check that each CI/CO has a name
continue; Abc_NtkForEachCi( pNtk, pObj, i )
pObj = Abc_ObjFanin0Ntk(pObj);
if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
{ {
fprintf( stdout, "NetworkCheck: CO with ID %d is in the network but not in the name table.\n", pObj->Id ); pObj = Abc_ObjFanout0Ntk(pObj);
return 0; if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
{
fprintf( stdout, "NetworkCheck: CI with ID %d is in the network but not in the name table.\n", pObj->Id );
return 0;
}
} }
} Abc_NtkForEachCo( pNtk, pObj, i )
if ( Abc_NtkIsNetlist(pNtk) )
{
Abc_NtkForEachNet( pNtk, pObj, i )
{ {
pName = Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id); pObj = Abc_ObjFanin0Ntk(pObj);
if ( pObj->pData && strcmp( pName, pObj->pData ) != 0 ) if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
{ {
fprintf( stdout, "NetworkCheck: Net \"%s\" has different name in the name table and at the data pointer.\n", pObj->pData ); fprintf( stdout, "NetworkCheck: CO with ID %d is in the network but not in the name table.\n", pObj->Id );
return 0; return 0;
} }
} }
...@@ -543,7 +543,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode ) ...@@ -543,7 +543,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
return 0; return 0;
} }
} }
else if ( !Abc_NtkHasMapping(pNtk) ) else if ( !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasAig(pNtk) )
{ {
assert( 0 ); assert( 0 );
} }
...@@ -564,15 +564,10 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode ) ...@@ -564,15 +564,10 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch ) bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
{ {
int Value = 1; int Value = 1;
if ( pNtk->vLatches->nSize != Abc_NtkLatchNum(pNtk) )
{
fprintf( stdout, "NetworkCheck: Incorrect size of the latch array.\n" );
return 0;
}
// check whether the object is a latch // check whether the object is a latch
if ( !Abc_ObjIsLatch(pLatch) ) if ( !Abc_ObjIsLatch(pLatch) )
{ {
fprintf( stdout, "NodeCheck: Latch \"%s\" is in a latch list but has not latch label.\n", Abc_ObjName(pLatch) ); fprintf( stdout, "NodeCheck: Latch \"%s\" is in a latch list but is not a latch.\n", Abc_ObjName(pLatch) );
Value = 0; Value = 0;
} }
// make sure the latch has a reasonable return value // make sure the latch has a reasonable return value
...@@ -588,6 +583,12 @@ bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch ) ...@@ -588,6 +583,12 @@ bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanins.\n", Abc_ObjName(pLatch), Abc_ObjFaninNum(pLatch) ); fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanins.\n", Abc_ObjName(pLatch), Abc_ObjFaninNum(pLatch) );
Value = 0; Value = 0;
} }
// make sure the latch has only one fanin
if ( Abc_ObjFanoutNum(pLatch) != 1 )
{
fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanouts.\n", Abc_ObjName(pLatch), Abc_ObjFanoutNum(pLatch) );
Value = 0;
}
return Value; return Value;
} }
...@@ -671,24 +672,26 @@ bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -671,24 +672,26 @@ bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
bool Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) bool Abc_NtkCompareBoxes( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{ {
Abc_Obj_t * pObj1; Abc_Obj_t * pObj1;
int i; int i;
assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
if ( !fComb ) if ( !fComb )
return 1; return 1;
if ( Abc_NtkLatchNum(pNtk1) != Abc_NtkLatchNum(pNtk2) ) if ( Abc_NtkBoxNum(pNtk1) != Abc_NtkBoxNum(pNtk2) )
{ {
printf( "Networks have different number of latches.\n" ); printf( "Networks have different number of latches.\n" );
return 0; return 0;
} }
// for each PI of pNet1 find corresponding PI of pNet2 and reorder them // for each PI of pNet1 find corresponding PI of pNet2 and reorder them
Abc_NtkForEachLatch( pNtk1, pObj1, i ) Abc_NtkForEachBox( pNtk1, pObj1, i )
{ {
if ( strcmp( Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkLatch(pNtk2,i)) ) != 0 ) if ( strcmp( Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkBox(pNtk2,i)) ) != 0 )
{ {
printf( "Latch #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n", printf( "Box #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
i, Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkLatch(pNtk2,i)) ); i, Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkBox(pNtk2,i)) );
return 0; return 0;
} }
} }
...@@ -710,7 +713,7 @@ bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -710,7 +713,7 @@ bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{ {
Abc_NtkOrderObjsByName( pNtk1, fComb ); Abc_NtkOrderObjsByName( pNtk1, fComb );
Abc_NtkOrderObjsByName( pNtk2, fComb ); Abc_NtkOrderObjsByName( pNtk2, fComb );
if ( !Abc_NtkCompareLatches( pNtk1, pNtk2, fComb ) ) if ( !Abc_NtkCompareBoxes( pNtk1, pNtk2, fComb ) )
return 0; return 0;
if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) ) if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
return 0; return 0;
......
...@@ -45,10 +45,10 @@ bool Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot ) ...@@ -45,10 +45,10 @@ bool Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot )
assert( Abc_ObjIsLatch(pLatch) ); assert( Abc_ObjIsLatch(pLatch) );
if ( pLatch == pLatchRoot ) if ( pLatch == pLatchRoot )
return 1; return 1;
pFanin = Abc_ObjFanin0(pLatch); pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
if ( !Abc_ObjIsLatch(pFanin) ) if ( !Abc_ObjIsBi(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
return 0; return 0;
return Abc_NtkLatchIsSelfFeed_rec( pFanin, pLatch ); return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -66,10 +66,10 @@ bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch ) ...@@ -66,10 +66,10 @@ bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch )
{ {
Abc_Obj_t * pFanin; Abc_Obj_t * pFanin;
assert( Abc_ObjIsLatch(pLatch) ); assert( Abc_ObjIsLatch(pLatch) );
pFanin = Abc_ObjFanin0(pLatch); pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
if ( !Abc_ObjIsLatch(pFanin) ) if ( !Abc_ObjIsBi(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
return 0; return 0;
return Abc_NtkLatchIsSelfFeed_rec( pFanin, pLatch ); return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -121,7 +121,7 @@ int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk ) ...@@ -121,7 +121,7 @@ int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk )
pConst1 = Abc_AigConst1(pNtk); pConst1 = Abc_AigConst1(pNtk);
else else
pConst1 = Abc_NodeCreateConst1(pNtk); pConst1 = Abc_NodeCreateConst1(pNtk);
Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(pLatch), pConst1 ); Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
Counter++; Counter++;
} }
} }
...@@ -160,7 +160,7 @@ void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches ) ...@@ -160,7 +160,7 @@ void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches )
Abc_ObjAddFanin( pLatch, pFanin ); Abc_ObjAddFanin( pLatch, pFanin );
Abc_LatchSetInitDc( pLatch ); Abc_LatchSetInitDc( pLatch );
// create the name of the new latch // create the name of the new latch
Abc_NtkLogicStoreName( pLatch, Abc_ObjNameDummy("LL", i*nLatches + k, nDigits) ); Abc_ObjAssignName( pLatch, Abc_ObjNameDummy("LL", i*nLatches + k, nDigits), NULL );
} }
// patch the PI fanouts // patch the PI fanouts
Vec_PtrForEachEntry( vNodes, pFanout, k ) Vec_PtrForEachEntry( vNodes, pFanout, k )
......
...@@ -125,6 +125,7 @@ Abc_Ntk_t * Abc_LibDeriveRoot( Abc_Lib_t * pLib ) ...@@ -125,6 +125,7 @@ Abc_Ntk_t * Abc_LibDeriveRoot( Abc_Lib_t * pLib )
***********************************************************************/ ***********************************************************************/
int Abc_LibDeriveBlackBoxes( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib ) int Abc_LibDeriveBlackBoxes( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
{ {
/*
Abc_Obj_t * pObj, * pFanin, * pFanout; Abc_Obj_t * pObj, * pFanin, * pFanout;
int i, k; int i, k;
assert( Abc_NtkIsNetlist(pNtk) ); assert( Abc_NtkIsNetlist(pNtk) );
...@@ -161,6 +162,8 @@ int Abc_LibDeriveBlackBoxes( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib ) ...@@ -161,6 +162,8 @@ int Abc_LibDeriveBlackBoxes( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
} }
} }
return Vec_PtrSize(pNtk->vBoxes); return Vec_PtrSize(pNtk->vBoxes);
*/
return 1;
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -60,7 +60,7 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk ) ...@@ -60,7 +60,7 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc );
// duplicate the nodes // duplicate the nodes
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj, 0);
// reconnect the internal nodes in the new network // reconnect the internal nodes in the new network
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k ) Abc_ObjForEachFanin( pObj, pFanin, k )
...@@ -109,13 +109,13 @@ Abc_Ntk_t * Abc_NtkNetlistToLogicHie( Abc_Ntk_t * pNtk ) ...@@ -109,13 +109,13 @@ Abc_Ntk_t * Abc_NtkNetlistToLogicHie( Abc_Ntk_t * pNtk )
// clone PIs/POs/latches and make old nets point to new terminals; create names // clone PIs/POs/latches and make old nets point to new terminals; create names
Abc_NtkForEachCi( pNtk, pObj, i ) Abc_NtkForEachCi( pNtk, pObj, i )
{ {
Abc_ObjFanout0(pObj)->pCopy = Abc_NtkDupObj(pNtkNew, pObj); Abc_ObjFanout0(pObj)->pCopy = Abc_NtkDupObj(pNtkNew, pObj, 0);
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0(pObj)) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0(pObj)), NULL );
} }
Abc_NtkForEachPo( pNtk, pObj, i ) Abc_NtkForEachPo( pNtk, pObj, i )
{ {
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj, 0);
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0(pObj)) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0(pObj)), NULL );
} }
// recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes // recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes
Abc_NtkNetlistToLogicHie_rec( pNtkNew, pNtk, &Counter ); Abc_NtkNetlistToLogicHie_rec( pNtkNew, pNtk, &Counter );
...@@ -164,7 +164,7 @@ void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int ...@@ -164,7 +164,7 @@ void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int
if ( Abc_ObjIsNode(pNode) ) if ( Abc_ObjIsNode(pNode) )
{ {
// duplicate the node and save it in the fanout net // duplicate the node and save it in the fanout net
Abc_NtkDupObj( pNtkNew, pNode ); Abc_NtkDupObj( pNtkNew, pNode, 0 );
Abc_ObjFanout0(pNode)->pCopy = pNode->pCopy; Abc_ObjFanout0(pNode)->pCopy = pNode->pCopy;
continue; continue;
} }
...@@ -184,14 +184,14 @@ void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int ...@@ -184,14 +184,14 @@ void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int
{ {
pObj->pCopy = Abc_NtkCreatePi( pNtkNew ); pObj->pCopy = Abc_NtkCreatePi( pNtkNew );
Abc_ObjFanout(pNode, k)->pCopy = pObj->pCopy; Abc_ObjFanout(pNode, k)->pCopy = pObj->pCopy;
Abc_NtkLogicStoreNamePlus( pObj->pCopy, Prefix, Abc_ObjName(Abc_ObjFanin0(pObj)) ); Abc_ObjAssignName( pObj->pCopy, Prefix, Abc_ObjName(Abc_ObjFanin0(pObj)) );
} }
// create new POs from the PIs of the box // create new POs from the PIs of the box
Abc_NtkForEachPi( pNtkModel, pObj, k ) Abc_NtkForEachPi( pNtkModel, pObj, k )
{ {
pObj->pCopy = Abc_NtkCreatePo( pNtkNew ); pObj->pCopy = Abc_NtkCreatePo( pNtkNew );
// Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin(pNode, k)->pCopy ); // Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin(pNode, k)->pCopy );
Abc_NtkLogicStoreNamePlus( pObj->pCopy, Prefix, Abc_ObjName(Abc_ObjFanout0(pObj)) ); Abc_ObjAssignName( pObj->pCopy, Prefix, Abc_ObjName(Abc_ObjFanout0(pObj)) );
} }
(*pCounter)++; (*pCounter)++;
Vec_IntPush( pNtkNew->pBlackBoxes, (Abc_NtkPiNum(pNtkNew) << 16) | Abc_NtkPoNum(pNtkNew) ); Vec_IntPush( pNtkNew->pBlackBoxes, (Abc_NtkPiNum(pNtkNew) << 16) | Abc_NtkPoNum(pNtkNew) );
...@@ -319,12 +319,10 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk ) ...@@ -319,12 +319,10 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
{ {
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin; Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin;
char * pNameCo;
int i, k; int i, k;
assert( Abc_NtkIsLogic(pNtk) ); assert( Abc_NtkIsLogic(pNtk) );
assert( Abc_NtkLogicHasSimpleCos(pNtk) ); assert( Abc_NtkLogicHasSimpleCos(pNtk) );
if ( Abc_NtkIsBddLogic(pNtk) ) if ( Abc_NtkIsBddLogic(pNtk) )
{ {
if ( !Abc_NtkBddToSop(pNtk,0) ) if ( !Abc_NtkBddToSop(pNtk,0) )
...@@ -333,22 +331,19 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk ) ...@@ -333,22 +331,19 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
// start the netlist by creating PI/PO/Latch objects // start the netlist by creating PI/PO/Latch objects
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc );
// create the CI nets and remember them in the new CI nodes // create the CI nets and remember them in the new CI nodes
Abc_NtkForEachCi( pNtk, pObj, i ) Abc_NtkForEachCi( pNtk, pObj, i )
{ {
pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) ); pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
Abc_ObjAddFanin( pNet, pObj->pCopy ); Abc_ObjAddFanin( pNet, pObj->pCopy );
pObj->pCopy->pCopy = pNet; pObj->pCopy->pCopy = pNet;
//printf( "%s ", Abc_ObjName(pObj) );
} }
//printf( "\n" );
// duplicate all nodes // duplicate all nodes
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
{ {
if ( Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 ) if ( Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
continue; continue;
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj, 0);
} }
// first add the nets to the CO drivers // first add the nets to the CO drivers
Abc_NtkForEachCo( pNtk, pObj, i ) Abc_NtkForEachCo( pNtk, pObj, i )
...@@ -361,18 +356,18 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk ) ...@@ -361,18 +356,18 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
continue; continue;
} }
assert( Abc_ObjIsNode(pDriver) ); assert( Abc_ObjIsNode(pDriver) );
// the driver is a node // if the CO drive has no net, create it
if ( pDriver->pCopy->pCopy == NULL )
// get the CO name {
pNameCo = Abc_ObjIsLatch(pObj)? Abc_ObjNameSuffix( pObj, "_in" ) : Abc_ObjName(pObj); // create the CO net and connect it to CO
// make sure CO has a unique name pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
assert( Abc_NtkFindNet( pNtkNew, pNameCo ) == NULL ); Abc_ObjAddFanin( pObj->pCopy, pNet );
// create the CO net and connect it to CO // connect the CO net to the new driver and remember it in the new driver
pNet = Abc_NtkFindOrCreateNet( pNtkNew, pNameCo ); Abc_ObjAddFanin( pNet, pDriver->pCopy );
Abc_ObjAddFanin( pObj->pCopy, pNet ); pDriver->pCopy->pCopy = pNet;
// connect the CO net to the new driver and remember it in the new driver }
Abc_ObjAddFanin( pNet, pDriver->pCopy ); else
pDriver->pCopy->pCopy = pNet; assert( !strcmp( Abc_ObjName(pDriver->pCopy->pCopy), Abc_ObjName(pObj) ) );
} }
// create the missing nets // create the missing nets
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
...@@ -425,7 +420,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk ) ...@@ -425,7 +420,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk )
// duplicate the nodes and create node functions // duplicate the nodes and create node functions
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
{ {
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj, 0);
pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) ); pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
} }
// create the choice nodes // create the choice nodes
...@@ -519,7 +514,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk ) ...@@ -519,7 +514,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk )
// duplicate the nodes, create node functions, and inverters // duplicate the nodes, create node functions, and inverters
Vec_PtrForEachEntry( vNodes, pObj, i ) Vec_PtrForEachEntry( vNodes, pObj, i )
{ {
Abc_NtkDupObj( pNtkNew, pObj ); Abc_NtkDupObj( pNtkNew, pObj, 0 );
pObj->pCopy->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, 2, NULL ); pObj->pCopy->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, 2, NULL );
if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) ) if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
pObj->pCopy->pCopy = Abc_NodeCreateInv( pNtkNew, pObj->pCopy ); pObj->pCopy->pCopy = Abc_NodeCreateInv( pNtkNew, pObj->pCopy );
......
...@@ -99,7 +99,7 @@ void Abc_ObjRecycle( Abc_Obj_t * pObj ) ...@@ -99,7 +99,7 @@ void Abc_ObjRecycle( Abc_Obj_t * pObj )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NtkObjAdd( Abc_Ntk_t * pNtk, Abc_ObjType_t Type ) Abc_Obj_t * Abc_NtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
// create new object, assign ID, and add to the array // create new object, assign ID, and add to the array
...@@ -139,16 +139,14 @@ Abc_Obj_t * Abc_NtkObjAdd( Abc_Ntk_t * pNtk, Abc_ObjType_t Type ) ...@@ -139,16 +139,14 @@ Abc_Obj_t * Abc_NtkObjAdd( Abc_Ntk_t * pNtk, Abc_ObjType_t Type )
Vec_PtrPush( pNtk->vCos, pObj ); Vec_PtrPush( pNtk->vCos, pObj );
break; break;
case ABC_OBJ_NET: case ABC_OBJ_NET:
break;
case ABC_OBJ_NODE: case ABC_OBJ_NODE:
case ABC_OBJ_GATE:
break; break;
case ABC_OBJ_LATCH: case ABC_OBJ_LATCH:
pObj->pData = (void *)ABC_INIT_NONE; pObj->pData = (void *)ABC_INIT_NONE;
Vec_PtrPush( pNtk->vLatches, pObj ); case ABC_OBJ_TRI:
Vec_PtrPush( pNtk->vCis, pObj ); case ABC_OBJ_BLACKBOX:
Vec_PtrPush( pNtk->vCos, pObj ); Vec_PtrPush( pNtk->vBoxes, pObj );
break;
case ABC_OBJ_BOX:
break; break;
default: default:
assert(0); assert(0);
...@@ -189,8 +187,8 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj ) ...@@ -189,8 +187,8 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
pNtk->nObjCounts[pObj->Type]--; pNtk->nObjCounts[pObj->Type]--;
pNtk->nObjs--; pNtk->nObjs--;
// remove from the table of names // remove from the table of names
// if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) ) if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
// Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id); Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
// perform specialized operations depending on the object type // perform specialized operations depending on the object type
switch (pObj->Type) switch (pObj->Type)
{ {
...@@ -222,7 +220,7 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj ) ...@@ -222,7 +220,7 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
Vec_PtrRemove( pNtk->vCos, pObj ); Vec_PtrRemove( pNtk->vCos, pObj );
break; break;
case ABC_OBJ_NET: case ABC_OBJ_NET:
pObj->pData = NULL; case ABC_OBJ_GATE:
break; break;
case ABC_OBJ_NODE: case ABC_OBJ_NODE:
if ( Abc_NtkHasBdd(pNtk) ) if ( Abc_NtkHasBdd(pNtk) )
...@@ -230,11 +228,9 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj ) ...@@ -230,11 +228,9 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
pObj->pData = NULL; pObj->pData = NULL;
break; break;
case ABC_OBJ_LATCH: case ABC_OBJ_LATCH:
Vec_PtrRemove( pNtk->vLatches, pObj ); case ABC_OBJ_TRI:
Vec_PtrRemove( pNtk->vCis, pObj ); case ABC_OBJ_BLACKBOX:
Vec_PtrRemove( pNtk->vCos, pObj ); Vec_PtrRemove( pNtk->vBoxes, pObj );
break;
case ABC_OBJ_BOX:
break; break;
default: default:
assert(0); assert(0);
...@@ -283,11 +279,21 @@ void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj ) ...@@ -283,11 +279,21 @@ void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName )
{ {
Abc_Obj_t * pObjNew; Abc_Obj_t * pObjNew;
// create the new object // create the new object
pObjNew = Abc_NtkObjAdd( pNtkNew, pObj->Type ); pObjNew = Abc_NtkCreateObj( pNtkNew, pObj->Type );
// transfer names of the terminal objects
if ( fCopyName )
{
if ( Abc_ObjIsCi(pObj) )
Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
else if ( Abc_ObjIsCo(pObj) )
Abc_ObjAssignName( pObjNew, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
else if ( Abc_ObjIsBox(pObj) )
Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
}
// copy functionality/names // copy functionality/names
if ( Abc_ObjIsNode(pObj) ) // copy the function if functionality is compatible if ( Abc_ObjIsNode(pObj) ) // copy the function if functionality is compatible
{ {
...@@ -308,7 +314,8 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) ...@@ -308,7 +314,8 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
} }
else if ( Abc_ObjIsNet(pObj) ) // copy the name else if ( Abc_ObjIsNet(pObj) ) // copy the name
{ {
pObjNew->pData = Nm_ManStoreIdName( pNtkNew->pManName, pObjNew->Id, pObj->pData, NULL ); assert( 0 );
// pObjNew->pData = Nm_ManStoreIdName( pNtkNew->pManName, pObjNew->Id, pObj->pData, NULL );
} }
else if ( Abc_ObjIsLatch(pObj) ) // copy the reset value else if ( Abc_ObjIsLatch(pObj) ) // copy the reset value
pObjNew->pData = pObj->pData; pObjNew->pData = pObj->pData;
...@@ -318,6 +325,33 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) ...@@ -318,6 +325,33 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Duplicates the latch with its input/output terminals.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_NtkDupBox( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pBox, int fCopyName )
{
Abc_Obj_t * pTerm, * pBoxNew;
int i;
assert( Abc_ObjIsBox(pBox) );
// duplicate the box
pBoxNew = Abc_NtkDupObj( pNtkNew, pBox, fCopyName );
// duplicate the fanins and connect them
Abc_ObjForEachFanin( pBox, pTerm, i )
Abc_ObjAddFanin( pBoxNew, Abc_NtkDupObj(pNtkNew, pTerm, fCopyName) );
// duplicate the fanouts and connect them
Abc_ObjForEachFanout( pBox, pTerm, i )
Abc_ObjAddFanin( Abc_NtkDupObj(pNtkNew, pTerm, fCopyName), pBoxNew );
return pBoxNew;
}
/**Function*************************************************************
Synopsis [Clones the objects in the same network but does not assign its function.] Synopsis [Clones the objects in the same network but does not assign its function.]
Description [] Description []
...@@ -331,7 +365,7 @@ Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj ) ...@@ -331,7 +365,7 @@ Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj )
{ {
Abc_Obj_t * pClone, * pFanin; Abc_Obj_t * pClone, * pFanin;
int i; int i;
pClone = Abc_NtkObjAdd( pObj->pNtk, pObj->Type ); pClone = Abc_NtkCreateObj( pObj->pNtk, pObj->Type );
Abc_ObjForEachFanin( pObj, pFanin, i ) Abc_ObjForEachFanin( pObj, pFanin, i )
Abc_ObjAddFanin( pClone, pFanin ); Abc_ObjAddFanin( pClone, pFanin );
return pClone; return pClone;
...@@ -351,34 +385,18 @@ Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj ) ...@@ -351,34 +385,18 @@ Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj )
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName ) Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
{ {
Abc_Obj_t * pObj, * pDriver; Abc_Obj_t * pObj;
int i, Num; int Num;
// check if the node is among CIs // try to find the terminal
Abc_NtkForEachCi( pNtk, pObj, i ) Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
{ if ( Num >= 0 )
if ( strcmp( Abc_ObjName(pObj), pName ) == 0 ) return Abc_NtkObj( pNtk, Num );
{ Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
if ( i < Abc_NtkPiNum(pNtk) ) if ( Num >= 0 )
printf( "Node \"%s\" is a primary input.\n", pName ); return Abc_NtkObj( pNtk, Num );
else Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NODE );
printf( "Node \"%s\" is a latch output.\n", pName ); if ( Num >= 0 )
return NULL; return Abc_NtkObj( pNtk, Num );
}
}
// search the node among COs
Abc_NtkForEachCo( pNtk, pObj, i )
{
if ( strcmp( Abc_ObjName(pObj), pName ) == 0 )
{
pDriver = Abc_ObjFanin0(pObj);
if ( !Abc_ObjIsNode(pDriver) )
{
printf( "Node \"%s\" does not have logic associated with it.\n", pName );
return NULL;
}
return pDriver;
}
}
// find the internal node // find the internal node
if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' ) if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' )
{ {
...@@ -421,7 +439,7 @@ Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName ) ...@@ -421,7 +439,7 @@ Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName )
Abc_Obj_t * pNet; Abc_Obj_t * pNet;
int ObjId; int ObjId;
assert( Abc_NtkIsNetlist(pNtk) ); assert( Abc_NtkIsNetlist(pNtk) );
ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, NULL ); ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NET );
if ( ObjId == -1 ) if ( ObjId == -1 )
return NULL; return NULL;
pNet = Abc_NtkObj( pNtk, ObjId ); pNet = Abc_NtkObj( pNtk, ObjId );
...@@ -430,29 +448,55 @@ Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName ) ...@@ -430,29 +448,55 @@ Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Returns the CI/CO terminal with the given name.] Synopsis [Returns CI with the given name.]
Description [] Description []
SideEffects [] SideEffects []
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NtkFindTerm( Abc_Ntk_t * pNtk, char * pName ) Abc_Obj_t * Abc_NtkFindCi( Abc_Ntk_t * pNtk, char * pName )
{ {
Abc_Obj_t * pNet; int Num;
int ObjId;
assert( !Abc_NtkIsNetlist(pNtk) ); assert( !Abc_NtkIsNetlist(pNtk) );
ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, NULL ); Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PI );
if ( ObjId == -1 ) if ( Num >= 0 )
return NULL; return Abc_NtkObj( pNtk, Num );
pNet = Abc_NtkObj( pNtk, ObjId ); Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
return pNet; if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num );
return NULL;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Returns CO with the given name.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_NtkFindCo( Abc_Ntk_t * pNtk, char * pName )
{
int Num;
assert( !Abc_NtkIsNetlist(pNtk) );
Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PO );
if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num );
Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num );
return NULL;
}
/**Function*************************************************************
Synopsis [Finds or creates the net.] Synopsis [Finds or creates the net.]
Description [] Description []
...@@ -469,8 +513,9 @@ Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName ) ...@@ -469,8 +513,9 @@ Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName )
if ( pName && (pNet = Abc_NtkFindNet( pNtk, pName )) ) if ( pName && (pNet = Abc_NtkFindNet( pNtk, pName )) )
return pNet; return pNet;
// create a new net // create a new net
pNet = Abc_NtkObjAdd( pNtk, ABC_OBJ_NET ); pNet = Abc_NtkCreateObj( pNtk, ABC_OBJ_NET );
pNet->pData = pName? Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pName, NULL ) : NULL; if ( pName )
Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pNet->Type, pName, NULL );
return pNet; return pNet;
} }
......
...@@ -47,7 +47,7 @@ void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk ) ...@@ -47,7 +47,7 @@ void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
if ( pNtk->nTravIds == (1<<8)-1 ) if ( pNtk->nTravIds == (1<<30)-1 )
{ {
pNtk->nTravIds = 0; pNtk->nTravIds = 0;
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
...@@ -69,8 +69,8 @@ void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk ) ...@@ -69,8 +69,8 @@ void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk )
***********************************************************************/ ***********************************************************************/
void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk ) void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj, * pTerm;
int i; int i, k;
Vec_PtrClear( pNtk->vCis ); Vec_PtrClear( pNtk->vCis );
Vec_PtrClear( pNtk->vCos ); Vec_PtrClear( pNtk->vCos );
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
...@@ -79,10 +79,12 @@ void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk ) ...@@ -79,10 +79,12 @@ void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk )
Vec_PtrPush( pNtk->vCos, pObj ); Vec_PtrPush( pNtk->vCos, pObj );
Abc_NtkForEachAssert( pNtk, pObj, i ) Abc_NtkForEachAssert( pNtk, pObj, i )
Vec_PtrPush( pNtk->vCos, pObj ); Vec_PtrPush( pNtk->vCos, pObj );
Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_NtkForEachBox( pNtk, pObj, i )
{ {
Vec_PtrPush( pNtk->vCis, pObj ); Abc_ObjForEachFanin( pObj, pTerm, k )
Vec_PtrPush( pNtk->vCos, pObj ); Vec_PtrPush( pNtk->vCos, pTerm );
Abc_ObjForEachFanout( pObj, pTerm, k )
Vec_PtrPush( pNtk->vCis, pTerm );
} }
} }
...@@ -433,11 +435,34 @@ void Abc_NtkCleanMarkA( Abc_Ntk_t * pNtk ) ...@@ -433,11 +435,34 @@ void Abc_NtkCleanMarkA( Abc_Ntk_t * pNtk )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Checks if the internal node has a unique CO.] Synopsis [Checks if the internal node has CO fanout.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_NodeHasCoFanout( Abc_Obj_t * pNode )
{
Abc_Obj_t * pFanout;
int i;
if ( !Abc_ObjIsNode(pNode) )
return NULL;
Abc_ObjForEachFanout( pNode, pFanout, i )
if ( Abc_ObjIsCo(pFanout) )
return pFanout;
return NULL;
}
/**Function*************************************************************
Synopsis [Checks if the internal node has CO drivers with the same name.]
Description [Checks if the internal node can borrow a name from a CO Description [Checks if the internal node can borrow a name from CO fanouts.
fanout. This is possible if there is only one CO with non-complemented This is possible if all COs with non-complemented fanin edge pointing to this
fanin edge pointing to this node.] node have the same name.]
SideEffects [] SideEffects []
...@@ -447,23 +472,27 @@ void Abc_NtkCleanMarkA( Abc_Ntk_t * pNtk ) ...@@ -447,23 +472,27 @@ void Abc_NtkCleanMarkA( Abc_Ntk_t * pNtk )
Abc_Obj_t * Abc_NodeHasUniqueCoFanout( Abc_Obj_t * pNode ) Abc_Obj_t * Abc_NodeHasUniqueCoFanout( Abc_Obj_t * pNode )
{ {
Abc_Obj_t * pFanout, * pFanoutCo; Abc_Obj_t * pFanout, * pFanoutCo;
int i, Counter; int i;
if ( !Abc_ObjIsNode(pNode) ) if ( !Abc_ObjIsNode(pNode) )
return NULL; return NULL;
Counter = 0; pFanoutCo = NULL;
Abc_ObjForEachFanout( pNode, pFanout, i ) Abc_ObjForEachFanout( pNode, pFanout, i )
{ {
if ( Abc_ObjIsCo(pFanout) && !Abc_ObjFaninC0(pFanout) ) if ( !Abc_ObjIsCo(pFanout) )
continue;
if ( Abc_ObjFaninC0(pFanout) )
continue;
if ( pFanoutCo == NULL )
{ {
assert( Abc_ObjFaninNum(pFanout) == 1 ); assert( Abc_ObjFaninNum(pFanout) == 1 );
assert( Abc_ObjFanin0(pFanout) == pNode ); assert( Abc_ObjFanin0(pFanout) == pNode );
pFanoutCo = pFanout; pFanoutCo = pFanout;
Counter++; continue;
} }
if ( strcmp( Abc_ObjName(pFanoutCo), Abc_ObjName(pFanout) ) ) // they have diff names
return NULL;
} }
if ( Counter == 1 ) return pFanoutCo;
return pFanoutCo;
return NULL;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -508,7 +537,7 @@ bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk ) ...@@ -508,7 +537,7 @@ bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk )
Description [The COs of a logic network are simple under three conditions: Description [The COs of a logic network are simple under three conditions:
(1) The edge from the CO to its driver is not complemented. (1) The edge from the CO to its driver is not complemented.
(2) No two COs share the same driver. (2) No two COs share the same driver (unless they have the same name!).
(3) The driver is not a CI unless the CI and the CO have the same name (3) The driver is not a CI unless the CI and the CO have the same name
(and so the inv/buf should not be written into a file). (and so the inv/buf should not be written into a file).
In some cases, such as FPGA mapping, we prevent the increase in delay In some cases, such as FPGA mapping, we prevent the increase in delay
...@@ -537,15 +566,15 @@ int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, bool fDuplicate ) ...@@ -537,15 +566,15 @@ int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, bool fDuplicate )
continue; continue;
} }
} }
else else if ( !Abc_ObjFaninC0(pNode) )
{ {
// skip the case when the driver's unique CO fanout is this CO // skip the case when all CO fanouts of the driver have the same name
if ( Abc_NodeHasUniqueCoFanout(pDriver) == pNode ) if ( Abc_NodeHasUniqueCoFanout(pDriver) )
continue; continue;
} }
if ( fDuplicate && !Abc_ObjIsCi(pDriver) ) if ( fDuplicate && !Abc_ObjIsCi(pDriver) )
{ {
pDriverNew = Abc_NtkDupObj( pNtk, pDriver ); pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
Abc_ObjForEachFanin( pDriver, pFanin, k ) Abc_ObjForEachFanin( pDriver, pFanin, k )
Abc_ObjAddFanin( pDriverNew, pFanin ); Abc_ObjAddFanin( pDriverNew, pFanin );
if ( Abc_ObjFaninC0(pNode) ) if ( Abc_ObjFaninC0(pNode) )
...@@ -1091,11 +1120,21 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk ) ...@@ -1091,11 +1120,21 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
pNode->Id = Vec_PtrSize( vObjsNew ); pNode->Id = Vec_PtrSize( vObjsNew );
Vec_PtrPush( vObjsNew, pNode ); Vec_PtrPush( vObjsNew, pNode );
} }
// put latches next // put latches and their inputs/outputs next
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachBox( pNtk, pNode, i )
{ {
pNode->Id = Vec_PtrSize( vObjsNew ); pNode->Id = Vec_PtrSize( vObjsNew );
Vec_PtrPush( vObjsNew, pNode ); Vec_PtrPush( vObjsNew, pNode );
Abc_ObjForEachFanin( pNode, pTemp, k )
{
pTemp->Id = Vec_PtrSize( vObjsNew );
Vec_PtrPush( vObjsNew, pTemp );
}
Abc_ObjForEachFanout( pNode, pTemp, k )
{
pTemp->Id = Vec_PtrSize( vObjsNew );
Vec_PtrPush( vObjsNew, pTemp );
}
} }
// finally, internal nodes in the DFS order // finally, internal nodes in the DFS order
vNodes = Abc_AigDfs( pNtk, 1, 0 ); vNodes = Abc_AigDfs( pNtk, 1, 0 );
...@@ -1139,6 +1178,7 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk ) ...@@ -1139,6 +1178,7 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
***********************************************************************/ ***********************************************************************/
void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk ) void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk )
{ {
/*
Abc_Obj_t * pLatch, * pFanin; Abc_Obj_t * pLatch, * pFanin;
int i, nTFFs, nJKFFs; int i, nTFFs, nJKFFs;
nTFFs = nJKFFs = 0; nTFFs = nJKFFs = 0;
...@@ -1157,13 +1197,6 @@ void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk ) ...@@ -1157,13 +1197,6 @@ void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk )
Abc_ObjFaninNum( Abc_ObjFanin1(pFanin) ) != 2 ) Abc_ObjFaninNum( Abc_ObjFanin1(pFanin) ) != 2 )
continue; continue;
/*
if ( !Abc_ObjFaninC0(pLatch) ||
!Abc_ObjFaninC0( Abc_ObjFanin0(pFanin) ) ||
!Abc_ObjFaninC1( Abc_ObjFanin0(pFanin) ) )
continue;
*/
if ( (Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch || if ( (Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch ||
Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch) && Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch) &&
(Abc_ObjFanin0(Abc_ObjFanin1(pFanin)) == pLatch || (Abc_ObjFanin0(Abc_ObjFanin1(pFanin)) == pLatch ||
...@@ -1174,6 +1207,7 @@ void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk ) ...@@ -1174,6 +1207,7 @@ void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk )
} }
printf( "D = %6d. T = %6d. JK = %6d. (%6.2f %%)\n", printf( "D = %6d. T = %6d. JK = %6d. (%6.2f %%)\n",
Abc_NtkLatchNum(pNtk), nTFFs, nJKFFs, 100.0 * nJKFFs / Abc_NtkLatchNum(pNtk) ); Abc_NtkLatchNum(pNtk), nTFFs, nJKFFs, 100.0 * nJKFFs / Abc_NtkLatchNum(pNtk) );
*/
} }
......
...@@ -3901,8 +3901,7 @@ int Abc_CommandOneOutput( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3901,8 +3901,7 @@ int Abc_CommandOneOutput( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( argc == globalUtilOptind + 1 ) if ( argc == globalUtilOptind + 1 )
{ {
pNodeCo = Abc_NtkFindTerm( pNtk, argv[globalUtilOptind] ); pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL ) if ( pNode == NULL )
{ {
fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] ); fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
...@@ -7433,6 +7432,8 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -7433,6 +7432,8 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
pOut = Abc_FrameReadOut(pAbc); pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc); pErr = Abc_FrameReadErr(pAbc);
printf( "This command is not implemented\n" );
// set defaults // set defaults
nFrames = 1; nFrames = 1;
fExdc = 1; fExdc = 1;
...@@ -7495,10 +7496,11 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -7495,10 +7496,11 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// get the new network // get the new network
if ( fImp ) // if ( fImp )
pNtkRes = Abc_NtkVanImp( pNtk, nFrames, fExdc, fVerbose ); // pNtkRes = Abc_NtkVanImp( pNtk, nFrames, fExdc, fVerbose );
else // else
pNtkRes = Abc_NtkVanEijk( pNtk, nFrames, fExdc, fVerbose ); // pNtkRes = Abc_NtkVanEijk( pNtk, nFrames, fExdc, fVerbose );
pNtkRes = NULL;
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
fprintf( pErr, "Sequential FPGA mapping has failed.\n" ); fprintf( pErr, "Sequential FPGA mapping has failed.\n" );
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk ); static Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkFromGlobalBddsDual( Abc_Ntk_t * pNtk );
static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc ); static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -59,10 +58,7 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i ...@@ -59,10 +58,7 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i
} }
// create the new network // create the new network
if ( fDualRail ) pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
pNtkNew = Abc_NtkFromGlobalBddsDual( pNtk );
else
pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
Abc_NtkFreeGlobalBdds( pNtk ); Abc_NtkFreeGlobalBdds( pNtk );
if ( pNtkNew == NULL ) if ( pNtkNew == NULL )
{ {
...@@ -134,42 +130,6 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk ) ...@@ -134,42 +130,6 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkFromGlobalBddsDual( Abc_Ntk_t * pNtk )
{
ProgressBar * pProgress;
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pNode, * pNodeNew;
DdManager * dd = pNtk->pManGlob;
int i;
// start the new network
pNtkNew = Abc_NtkStartFromDual( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
// make sure the new manager has the same number of inputs
Cudd_bddIthVar( pNtkNew->pManFunc, dd->size-1 );
// process the POs
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Cudd_Not( Vec_PtrEntry(pNtk->vFuncsGlob, i) ) );
Abc_ObjAddFanin( pNode->pCopy->pCopy, pNodeNew );
pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Vec_PtrEntry(pNtk->vFuncsGlob, i) );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
}
Extra_ProgressBarStop( pProgress );
return pNtkNew;
}
/**Function*************************************************************
Synopsis [Derives the network with the given global BDD.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc ) Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc )
{ {
Abc_Obj_t * pNodeNew, * pTemp; Abc_Obj_t * pNodeNew, * pTemp;
......
...@@ -502,6 +502,10 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ...@@ -502,6 +502,10 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i ) Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i )
{ {
pObjNew = Abc_NtkCreateLatch( pNtk ); pObjNew = Abc_NtkCreateLatch( pNtk );
pFaninNew0 = Abc_NtkCreateBo( pNtk );
pFaninNew1 = Abc_NtkCreateBi( pNtk );
Abc_ObjAddFanin( pObjNew, pFaninNew0 );
Abc_ObjAddFanin( pFaninNew1, pObjNew );
if ( fHaig || Ivy_ObjInit(pNode) == IVY_INIT_DC ) if ( fHaig || Ivy_ObjInit(pNode) == IVY_INIT_DC )
Abc_LatchSetInitDc( pObjNew ); Abc_LatchSetInitDc( pObjNew );
else if ( Ivy_ObjInit(pNode) == IVY_INIT_1 ) else if ( Ivy_ObjInit(pNode) == IVY_INIT_1 )
...@@ -509,8 +513,9 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ...@@ -509,8 +513,9 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
else if ( Ivy_ObjInit(pNode) == IVY_INIT_0 ) else if ( Ivy_ObjInit(pNode) == IVY_INIT_0 )
Abc_LatchSetInit0( pObjNew ); Abc_LatchSetInit0( pObjNew );
else assert( 0 ); else assert( 0 );
pNode->TravId = Abc_EdgeFromNode( pObjNew ); pNode->TravId = Abc_EdgeFromNode( pFaninNew1 );
} }
Abc_NtkAddDummyBoxNames( pNtk );
// rebuild the AIG // rebuild the AIG
Ivy_ManForEachNodeVec( pMan, vNodes, pNode, i ) Ivy_ManForEachNodeVec( pMan, vNodes, pNode, i )
{ {
...@@ -556,7 +561,7 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ...@@ -556,7 +561,7 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i ) Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i )
{ {
pFaninNew = Abc_ObjFanin0Ivy( pNtk, pNode ); pFaninNew = Abc_ObjFanin0Ivy( pNtk, pNode );
Abc_ObjAddFanin( Abc_NtkLatch(pNtk, i), pFaninNew ); Abc_ObjAddFanin( Abc_ObjFanin0(Abc_NtkBox(pNtk, i)), pFaninNew );
} }
Vec_IntFree( vLatches ); Vec_IntFree( vLatches );
Vec_IntFree( vNodes ); Vec_IntFree( vNodes );
......
...@@ -84,7 +84,7 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo ...@@ -84,7 +84,7 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo
Cudd_bddIthVar( pNtk->pManFunc, Vec_PtrSize(vNamesPi) ); Cudd_bddIthVar( pNtk->pManFunc, Vec_PtrSize(vNamesPi) );
// add the PIs corresponding to the names // add the PIs corresponding to the names
Vec_PtrForEachEntry( vNamesPi, pName, i ) Vec_PtrForEachEntry( vNamesPi, pName, i )
Abc_NtkLogicStoreName( Abc_NtkCreatePi(pNtk), pName ); Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), pName, NULL );
// create the node // create the node
pNode = Abc_NtkCreateNode( pNtk ); pNode = Abc_NtkCreateNode( pNtk );
pNode->pData = Cudd_bddTransfer( dd, pNtk->pManFunc, bFunc ); Cudd_Ref(pNode->pData); pNode->pData = Cudd_bddTransfer( dd, pNtk->pManFunc, bFunc ); Cudd_Ref(pNode->pData);
...@@ -93,7 +93,7 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo ...@@ -93,7 +93,7 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo
// create the only PO // create the only PO
pNodePo = Abc_NtkCreatePo( pNtk ); pNodePo = Abc_NtkCreatePo( pNtk );
Abc_ObjAddFanin( pNodePo, pNode ); Abc_ObjAddFanin( pNodePo, pNode );
Abc_NtkLogicStoreName( pNodePo, pNamePo ); Abc_ObjAssignName( pNodePo, pNamePo, NULL );
// make the network minimum base // make the network minimum base
Abc_NtkMinimumBase( pNtk ); Abc_NtkMinimumBase( pNtk );
if ( vNamesPiFake ) if ( vNamesPiFake )
...@@ -246,7 +246,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly ...@@ -246,7 +246,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
{ {
ProgressBar * pProgress; ProgressBar * pProgress;
Vec_Ptr_t * vFuncsGlob; Vec_Ptr_t * vFuncsGlob;
Abc_Obj_t * pNode, * pFanin; Abc_Obj_t * pObj, * pFanin;
DdNode * bFunc; DdNode * bFunc;
DdManager * dd; DdManager * dd;
int i, k, Counter; int i, k, Counter;
...@@ -264,17 +264,17 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly ...@@ -264,17 +264,17 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
// clean storage for local BDDs // clean storage for local BDDs
Abc_NtkCleanCopy( pNtk ); Abc_NtkCleanCopy( pNtk );
// set the elementary variables // set the elementary variables
Abc_NtkForEachCi( pNtk, pNode, i ) Abc_NtkForEachCi( pNtk, pObj, i )
if ( Abc_ObjFanoutNum(pNode) > 0 ) if ( Abc_ObjFanoutNum(pObj) > 0 )
{ {
pNode->pCopy = (Abc_Obj_t *)dd->vars[i]; pObj->pCopy = (Abc_Obj_t *)dd->vars[i];
Cudd_Ref( dd->vars[i] ); Cudd_Ref( dd->vars[i] );
} }
// assign the constant node BDD // assign the constant node BDD
pNode = Abc_AigConst1(pNtk); pObj = Abc_AigConst1(pNtk);
if ( Abc_ObjFanoutNum(pNode) > 0 ) if ( Abc_ObjFanoutNum(pObj) > 0 )
{ {
pNode->pCopy = (Abc_Obj_t *)dd->one; pObj->pCopy = (Abc_Obj_t *)dd->one;
Cudd_Ref( dd->one ); Cudd_Ref( dd->one );
} }
...@@ -285,9 +285,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly ...@@ -285,9 +285,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
{ {
// construct the BDDs // construct the BDDs
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachLatchInput( pNtk, pObj, i )
{ {
bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pNode), nBddSizeMax, pProgress, &Counter, fVerbose ); bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pObj), nBddSizeMax, pProgress, &Counter, fVerbose );
if ( bFunc == NULL ) if ( bFunc == NULL )
{ {
if ( fVerbose ) if ( fVerbose )
...@@ -296,7 +296,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly ...@@ -296,7 +296,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
Cudd_Quit( dd ); Cudd_Quit( dd );
return NULL; return NULL;
} }
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); Cudd_Ref( bFunc ); bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
Vec_PtrPush( vFuncsGlob, bFunc ); Vec_PtrPush( vFuncsGlob, bFunc );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
...@@ -305,9 +305,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly ...@@ -305,9 +305,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
{ {
// construct the BDDs // construct the BDDs
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i ) Abc_NtkForEachCo( pNtk, pObj, i )
{ {
bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pNode), nBddSizeMax, pProgress, &Counter, fVerbose ); bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pObj), nBddSizeMax, pProgress, &Counter, fVerbose );
if ( bFunc == NULL ) if ( bFunc == NULL )
{ {
if ( fVerbose ) if ( fVerbose )
...@@ -316,34 +316,35 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly ...@@ -316,34 +316,35 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
Cudd_Quit( dd ); Cudd_Quit( dd );
return NULL; return NULL;
} }
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); Cudd_Ref( bFunc ); bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
Vec_PtrPush( vFuncsGlob, bFunc ); Vec_PtrPush( vFuncsGlob, bFunc );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
} }
/* /*
// derefence the intermediate BDDs // derefence the intermediate BDDs
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pObj, i )
if ( pNode->pCopy ) if ( pObj->pCopy )
{ {
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy ); Cudd_RecursiveDeref( dd, (DdNode *)pObj->pCopy );
pNode->pCopy = NULL; pObj->pCopy = NULL;
} }
*/ */
/* /*
// make sure all nodes are derefed // make sure all nodes are derefed
Abc_NtkForEachObj( pNtk, pNode, i ) Abc_NtkForEachObj( pNtk, pObj, i )
{ {
if ( pNode->pCopy != NULL ) if ( pObj->pCopy != NULL )
printf( "Abc_NtkGlobalBdds() error: Node %d has BDD assigned\n", pNode->Id ); printf( "Abc_NtkGlobalBdds() error: Node %d has BDD assigned\n", pObj->Id );
if ( pNode->vFanouts.nSize > 0 ) if ( pObj->vFanouts.nSize > 0 )
printf( "Abc_NtkGlobalBdds() error: Node %d has refs assigned\n", pNode->Id ); printf( "Abc_NtkGlobalBdds() error: Node %d has refs assigned\n", pObj->Id );
} }
*/ */
// reset references // reset references
Abc_NtkForEachObj( pNtk, pNode, i ) Abc_NtkForEachObj( pNtk, pObj, i )
Abc_ObjForEachFanin( pNode, pFanin, k ) if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBi(pObj) )
pFanin->vFanouts.nSize++; Abc_ObjForEachFanin( pObj, pFanin, k )
pFanin->vFanouts.nSize++;
// reorder one more time // reorder one more time
if ( fReorder ) if ( fReorder )
......
...@@ -70,7 +70,7 @@ void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, ...@@ -70,7 +70,7 @@ void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse,
vSupp = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) ); vSupp = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
while ( fscanf( pFile, "%s", Buffer ) == 1 ) while ( fscanf( pFile, "%s", Buffer ) == 1 )
{ {
pObj = Abc_NtkFindTerm( pNtk, Buffer ); pObj = Abc_NtkFindCi( pNtk, Buffer );
if ( pObj == NULL || !Abc_ObjIsCi(pObj) ) if ( pObj == NULL || !Abc_ObjIsCi(pObj) )
{ {
printf( "Name \"%s\" is not a PI name. Cannot use this order.\n", Buffer ); printf( "Name \"%s\" is not a PI name. Cannot use this order.\n", Buffer );
......
...@@ -247,7 +247,7 @@ void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -247,7 +247,7 @@ void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk )
assert( Init < 4 ); assert( Init < 4 );
InitNums[Init]++; InitNums[Init]++;
pFanin = Abc_ObjFanin0(pLatch); pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
if ( !Abc_ObjIsNode(pFanin) || !Abc_NodeIsConst(pFanin) ) if ( !Abc_ObjIsNode(pFanin) || !Abc_NodeIsConst(pFanin) )
continue; continue;
......
...@@ -147,9 +147,9 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, bool fUpd ...@@ -147,9 +147,9 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, bool fUpd
if ( fUpdateLevel ) if ( fUpdateLevel )
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk );
if ( Abc_NtkLatchNum(pNtk) ) // if ( Abc_NtkLatchNum(pNtk) )
Abc_NtkForEachLatch(pNtk, pNode, i) // Abc_NtkForEachLatch(pNtk, pNode, i)
pNode->pNext = pNode->pData; // pNode->pNext = pNode->pData;
// resynthesize each node once // resynthesize each node once
nNodes = Abc_NtkObjNumMax(pNtk); nNodes = Abc_NtkObjNumMax(pNtk);
...@@ -221,9 +221,9 @@ pManRes->timeTotal = clock() - clkStart; ...@@ -221,9 +221,9 @@ pManRes->timeTotal = clock() - clkStart;
Abc_NtkForEachObj( pNtk, pNode, i ) Abc_NtkForEachObj( pNtk, pNode, i )
pNode->pData = NULL; pNode->pData = NULL;
if ( Abc_NtkLatchNum(pNtk) ) // if ( Abc_NtkLatchNum(pNtk) )
Abc_NtkForEachLatch(pNtk, pNode, i) // Abc_NtkForEachLatch(pNtk, pNode, i)
pNode->pData = pNode->pNext, pNode->pNext = NULL; // pNode->pData = pNode->pNext, pNode->pNext = NULL;
// put the nodes into the DFS order and reassign their IDs // put the nodes into the DFS order and reassign their IDs
Abc_NtkReassignIds( pNtk ); Abc_NtkReassignIds( pNtk );
......
...@@ -106,8 +106,8 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa ...@@ -106,8 +106,8 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
p->nNodesOld = Abc_NtkNodeNum(pNtk); p->nNodesOld = Abc_NtkNodeNum(pNtk);
p->nLevelsOld = Abc_AigGetLevelNum(pNtk); p->nLevelsOld = Abc_AigGetLevelNum(pNtk);
// remember latch values // remember latch values
Abc_NtkForEachLatch( pNtk, pNode, i ) // Abc_NtkForEachLatch( pNtk, pNode, i )
pNode->pNext = pNode->pData; // pNode->pNext = pNode->pData;
// go through the nodes // go through the nodes
Abc_NtkCleanCopy(pNtk); Abc_NtkCleanCopy(pNtk);
nNodes = Abc_NtkObjNumMax(pNtk); nNodes = Abc_NtkObjNumMax(pNtk);
...@@ -216,8 +216,8 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa ...@@ -216,8 +216,8 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
Abc_RRManPrintStats( p ); Abc_RRManPrintStats( p );
Abc_RRManStop( p ); Abc_RRManStop( p );
// restore latch values // restore latch values
Abc_NtkForEachLatch( pNtk, pNode, i ) // Abc_NtkForEachLatch( pNtk, pNode, i )
pNode->pData = pNode->pNext, pNode->pNext = NULL; // pNode->pData = pNode->pNext, pNode->pNext = NULL;
// put the nodes into the DFS order and reassign their IDs // put the nodes into the DFS order and reassign their IDs
Abc_NtkReassignIds( pNtk ); Abc_NtkReassignIds( pNtk );
Abc_NtkGetLevelNum( pNtk ); Abc_NtkGetLevelNum( pNtk );
......
...@@ -327,7 +327,7 @@ Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels ) ...@@ -327,7 +327,7 @@ Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels )
pPoNew = Abc_NtkCreatePo(pNtkNew); pPoNew = Abc_NtkCreatePo(pNtkNew);
Abc_ObjAddFanin( pPoNew, pObjNew ); Abc_ObjAddFanin( pPoNew, pObjNew );
Abc_NtkAddDummyPiNames( pNtkNew ); Abc_NtkAddDummyPiNames( pNtkNew );
Abc_NtkLogicStoreName( pPoNew, Abc_ObjName(Abc_NtkPo(pNtk, 0)) ); Abc_ObjAssignName( pPoNew, Abc_ObjName(Abc_NtkPo(pNtk, 0)), NULL );
// make sure everything is okay // make sure everything is okay
if ( !Abc_NtkCheck( pNtkNew ) ) if ( !Abc_NtkCheck( pNtkNew ) )
{ {
......
...@@ -59,11 +59,31 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose ) ...@@ -59,11 +59,31 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose )
Abc_Ntk_t * pNtkAig; Abc_Ntk_t * pNtkAig;
Fraig_Man_t * pMan; Fraig_Man_t * pMan;
stmm_table * tEquiv; stmm_table * tEquiv;
Abc_Obj_t * pObj;
int i, fUseTrick;
assert( !Abc_NtkIsStrash(pNtk) ); assert( !Abc_NtkIsStrash(pNtk) );
// save gate assignments
fUseTrick = 0;
if ( Abc_NtkIsMappedLogic(pNtk) )
{
fUseTrick = 1;
Abc_NtkForEachNode( pNtk, pObj, i )
pObj->pNext = pObj->pData;
}
// derive the AIG // derive the AIG
pNtkAig = Abc_NtkStrash( pNtk, 0, 1 ); pNtkAig = Abc_NtkStrash( pNtk, 0, 1 );
// reconstruct gate assignments
if ( fUseTrick )
{
extern void * Abc_FrameReadLibGen();
Aig_ManStop( pNtk->pManFunc );
pNtk->pManFunc = Abc_FrameReadLibGen();
pNtk->ntkFunc = ABC_FUNC_MAP;
Abc_NtkForEachNode( pNtk, pObj, i )
pObj->pData = pObj->pNext, pObj->pNext = NULL;
}
// perform fraiging of the AIG // perform fraiging of the AIG
Fraig_ParamsSetDefault( &Params ); Fraig_ParamsSetDefault( &Params );
...@@ -176,8 +196,8 @@ stmm_table * Abc_NtkFraigEquiv( Abc_Ntk_t * pNtk, int fUseInv, bool fVerbose ) ...@@ -176,8 +196,8 @@ stmm_table * Abc_NtkFraigEquiv( Abc_Ntk_t * pNtk, int fUseInv, bool fVerbose )
// skip the dangling nodes // skip the dangling nodes
if ( pNodeAig == NULL ) if ( pNodeAig == NULL )
continue; continue;
// skip the nodes that fanout into POs // skip the nodes that fanout into COs
if ( Abc_NodeHasUniqueCoFanout(pNode) ) if ( Abc_NodeHasCoFanout(pNode) )
continue; continue;
// get the FRAIG node // get the FRAIG node
gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, Abc_ObjIsComplement(pNodeAig) ); gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, Abc_ObjIsComplement(pNodeAig) );
......
...@@ -254,9 +254,9 @@ void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk ) ...@@ -254,9 +254,9 @@ void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk )
continue; continue;
*pTime = pNtk->pManTime->tReqDef; *pTime = pNtk->pManTime->tReqDef;
} }
// set the 0 arrival times for latches and constant nodes // set the 0 arrival times for latch outputs and constant nodes
ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray; ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray;
Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_NtkForEachLatchOutput( pNtk, pObj, i )
{ {
pTime = ppTimes[pObj->Id]; pTime = ppTimes[pObj->Id];
pTime->Fall = pTime->Rise = pTime->Worst = 0.0; pTime->Fall = pTime->Rise = pTime->Worst = 0.0;
......
...@@ -278,6 +278,7 @@ DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * b ...@@ -278,6 +278,7 @@ DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * b
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUnreach ) Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUnreach )
{ {
/*
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pNode, * pNodeNew; Abc_Obj_t * pNode, * pNodeNew;
int * pPermute; int * pPermute;
...@@ -290,7 +291,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn ...@@ -290,7 +291,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
// create PIs corresponding to LOs // create PIs corresponding to LOs
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachLatch( pNtk, pNode, i )
Abc_NtkLogicStoreName( pNode->pCopy = Abc_NtkCreatePi(pNtkNew), Abc_ObjName(pNode) ); Abc_ObjAssignName( pNode->pCopy = Abc_NtkCreatePi(pNtkNew), Abc_ObjName(pNode), NULL );
// cannot ADD POs here because pLatch->pCopy point to the PIs // cannot ADD POs here because pLatch->pCopy point to the PIs
// create a new node // create a new node
...@@ -313,9 +314,9 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn ...@@ -313,9 +314,9 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
// for each CO, create PO (skip POs equal to CIs because of name conflict) // for each CO, create PO (skip POs equal to CIs because of name conflict)
Abc_NtkForEachPo( pNtk, pNode, i ) Abc_NtkForEachPo( pNtk, pNode, i )
if ( !Abc_ObjIsCi(Abc_ObjFanin0(pNode)) ) if ( !Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
Abc_NtkLogicStoreName( pNode->pCopy = Abc_NtkCreatePo(pNtkNew), Abc_ObjName(pNode) ); Abc_ObjAssignName( pNode->pCopy = Abc_NtkCreatePo(pNtkNew), Abc_ObjName(pNode), NULL );
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachLatch( pNtk, pNode, i )
Abc_NtkLogicStoreName( pNode->pCopy = Abc_NtkCreatePo(pNtkNew), Abc_ObjNameSuffix(pNode, "_in") ); Abc_ObjAssignName( pNode->pCopy = Abc_NtkCreatePo(pNtkNew), Abc_ObjNameSuffix(pNode, "_in"), NULL );
// link to the POs of the network // link to the POs of the network
Abc_NtkForEachPo( pNtk, pNode, i ) Abc_NtkForEachPo( pNtk, pNode, i )
...@@ -337,6 +338,8 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn ...@@ -337,6 +338,8 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
return NULL; return NULL;
} }
return pNtkNew; return pNtkNew;
*/
return NULL;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -544,7 +544,7 @@ void Abc_NtkGetSeqPoSupp( Abc_Ntk_t * pNtk, int iFrame, int iNumPo ) ...@@ -544,7 +544,7 @@ void Abc_NtkGetSeqPoSupp( Abc_Ntk_t * pNtk, int iFrame, int iNumPo )
Abc_NtkForEachCi( pNtk, pObj, i ) Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = NULL; pObj->pCopy = NULL;
Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_NtkForEachLatch( pNtk, pObj, i )
if ( Abc_NtkLatch(pFrames, i)->pCopy ) if ( Abc_NtkBox(pFrames, i)->pCopy )
pObj->pCopy = (void *)1; pObj->pCopy = (void *)1;
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
for ( k = 0; k <= iFrame; k++ ) for ( k = 0; k <= iFrame; k++ )
......
...@@ -33,6 +33,4 @@ SRC += src/base/abci/abc.c \ ...@@ -33,6 +33,4 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcTiming.c \ src/base/abci/abcTiming.c \
src/base/abci/abcUnate.c \ src/base/abci/abcUnate.c \
src/base/abci/abcUnreach.c \ src/base/abci/abcUnreach.c \
src/base/abci/abcVanEijk.c \
src/base/abci/abcVanImp.c \
src/base/abci/abcVerify.c src/base/abci/abcVerify.c
...@@ -595,6 +595,9 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -595,6 +595,9 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
int fCheck; int fCheck;
int c; int c;
printf( "Stand-alone structural Verilog reader is now available as command \"read_ver\".\n" );
return 0;
fCheck = 1; fCheck = 1;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
...@@ -629,7 +632,8 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -629,7 +632,8 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
fclose( pFile ); fclose( pFile );
// set the new network // set the new network
pNtk = Io_ReadVerilog( FileName, fCheck ); // pNtk = Io_ReadVerilog( FileName, fCheck );
pNtk = NULL;
if ( pNtk == NULL ) if ( pNtk == NULL )
{ {
fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" ); fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" );
......
...@@ -49,7 +49,7 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck ) ...@@ -49,7 +49,7 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck )
if ( Extra_FileNameCheckExtension( pFileName, "blif" ) ) if ( Extra_FileNameCheckExtension( pFileName, "blif" ) )
pNtk = Io_ReadBlif( pFileName, fCheck ); pNtk = Io_ReadBlif( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "v" ) ) else if ( Extra_FileNameCheckExtension( pFileName, "v" ) )
pNtk = Io_ReadVerilog( pFileName, fCheck ); pNtk = NULL; //Io_ReadVerilog( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "bench" ) ) else if ( Extra_FileNameCheckExtension( pFileName, "bench" ) )
pNtk = Io_ReadBench( pFileName, fCheck ); pNtk = Io_ReadBench( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "edf" ) ) else if ( Extra_FileNameCheckExtension( pFileName, "edf" ) )
......
...@@ -85,21 +85,30 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck ) ...@@ -85,21 +85,30 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
for ( i = 0; i < nInputs; i++ ) for ( i = 0; i < nInputs; i++ )
{ {
pObj = Abc_NtkCreatePi(pNtkNew); pObj = Abc_NtkCreatePi(pNtkNew);
Abc_NtkLogicStoreName( pObj, pCur ); while ( *pCur++ ); Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
Vec_PtrPush( vNodes, pObj ); Vec_PtrPush( vNodes, pObj );
} }
// create the POs // create the POs
for ( i = 0; i < nOutputs; i++ ) for ( i = 0; i < nOutputs; i++ )
{ {
pObj = Abc_NtkCreatePo(pNtkNew); pObj = Abc_NtkCreatePo(pNtkNew);
Abc_NtkLogicStoreName( pObj, pCur ); while ( *pCur++ ); Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
} }
// create the latches // create the latches
for ( i = 0; i < nLatches; i++ ) for ( i = 0; i < nLatches; i++ )
{ {
pObj = Abc_NtkCreateLatch(pNtkNew); pObj = Abc_NtkCreateLatch(pNtkNew);
Abc_NtkLogicStoreName( pObj, pCur ); while ( *pCur++ ); Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
Vec_PtrPush( vNodes, pObj );
pNode0 = Abc_NtkCreateBo(pNtkNew);
Abc_ObjAssignName( pNode0, pCur, NULL ); while ( *pCur++ );
pNode1 = Abc_NtkCreateBi(pNtkNew);
Abc_ObjAssignName( pNode1, pCur, NULL ); while ( *pCur++ );
Vec_PtrPush( vNodes, pNode1 );
Abc_ObjAddFanin( pObj, pNode0 );
Abc_ObjAddFanin( pNode1, pObj );
} }
// get the pointer to the beginning of the node array // get the pointer to the beginning of the node array
...@@ -129,9 +138,9 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck ) ...@@ -129,9 +138,9 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
Abc_NtkForEachCo( pNtkNew, pObj, i ) Abc_NtkForEachCo( pNtkNew, pObj, i )
{ {
Num = pBufferNode[2*nAnds+i]; Num = pBufferNode[2*nAnds+i];
if ( Abc_ObjIsLatch(pObj) ) if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
{ {
Abc_ObjSetData( pObj, (void *)(Num & 3) ); Abc_ObjSetData( Abc_ObjFanout0(pObj), (void *)(Num & 3) );
Num >>= 2; Num >>= 2;
} }
pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, Num >> 1), Num & 1 ); pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, Num >> 1), Num & 1 );
......
...@@ -621,7 +621,7 @@ int Io_ReadBlifNetworkSubcircuit( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens ) ...@@ -621,7 +621,7 @@ int Io_ReadBlifNetworkSubcircuit( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
Vec_PtrPush( vNames, Extra_UtilStrsav(pName) ); // memory leak!!! Vec_PtrPush( vNames, Extra_UtilStrsav(pName) ); // memory leak!!!
// create a new box and add it to the network // create a new box and add it to the network
pBox = Abc_NtkCreateBox( p->pNtkCur ); pBox = Abc_NtkCreateBlackbox( p->pNtkCur );
// set the pointer to the node names // set the pointer to the node names
Abc_ObjSetData( pBox, vNames ); Abc_ObjSetData( pBox, vNames );
// remember the line of the file // remember the line of the file
......
...@@ -46,6 +46,9 @@ Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck ) ...@@ -46,6 +46,9 @@ Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck )
Extra_FileReader_t * p; Extra_FileReader_t * p;
Abc_Ntk_t * pNtk; Abc_Ntk_t * pNtk;
printf( "Currently this parser does not work!\n" );
return NULL;
// start the file // start the file
p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t()" ); p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t()" );
if ( p == NULL ) if ( p == NULL )
......
...@@ -116,15 +116,23 @@ Abc_Obj_t * Io_ReadCreateAssert( Abc_Ntk_t * pNtk, char * pName ) ...@@ -116,15 +116,23 @@ Abc_Obj_t * Io_ReadCreateAssert( Abc_Ntk_t * pNtk, char * pName )
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Io_ReadCreateLatch( Abc_Ntk_t * pNtk, char * pNetLI, char * pNetLO ) Abc_Obj_t * Io_ReadCreateLatch( Abc_Ntk_t * pNtk, char * pNetLI, char * pNetLO )
{ {
Abc_Obj_t * pLatch, * pNet; Abc_Obj_t * pLatch, * pTerm, * pNet;
// create a new latch and add it to the network
pLatch = Abc_NtkCreateLatch( pNtk );
// get the LI net // get the LI net
pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLI ); pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLI );
Abc_ObjAddFanin( pLatch, pNet ); // add the BO terminal
pTerm = Abc_NtkCreateBo( pNtk );
Abc_ObjAddFanin( pTerm, pNet );
// add the latch box
pLatch = Abc_NtkCreateLatch( pNtk );
Abc_ObjAddFanin( pLatch, pTerm );
// add the BI terminal
pTerm = Abc_NtkCreateBi( pNtk );
Abc_ObjAddFanin( pTerm, pLatch );
// get the LO net // get the LO net
pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO ); pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO );
Abc_ObjAddFanin( pNet, pLatch ); Abc_ObjAddFanin( pNet, pTerm );
// set latch name
Abc_ObjAssignName( pLatch, pNetLO, "_latch" );
return pLatch; return pLatch;
} }
......
...@@ -116,7 +116,11 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName ) ...@@ -116,7 +116,11 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 ); fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
// write latches // write latches
Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_NtkForEachLatch( pNtk, pObj, i )
{
fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 ); fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
fprintf( pFile, "%s%c", Abc_ObjName(Abc_ObjFanin0(pObj)), 0 );
fprintf( pFile, "%s%c", Abc_ObjName(Abc_ObjFanout0(pObj)), 0 );
}
// set the node numbers to be used in the output file // set the node numbers to be used in the output file
Abc_NtkCleanCopy( pNtk ); Abc_NtkCleanCopy( pNtk );
...@@ -143,8 +147,8 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName ) ...@@ -143,8 +147,8 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
{ {
Extra_ProgressBarUpdate( pProgress, nAnds, NULL ); Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
pBufferNode[nAnds] = (((int)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj); pBufferNode[nAnds] = (((int)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj);
if ( Abc_ObjIsLatch(pObj) ) if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((unsigned)Abc_ObjData(pObj) & 3); pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((unsigned)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3);
nAnds++; nAnds++;
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
......
...@@ -89,7 +89,7 @@ int Io_WriteBenchOne( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -89,7 +89,7 @@ int Io_WriteBenchOne( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, "OUTPUT(%s)\n", Abc_ObjName(Abc_ObjFanin0(pNode)) ); fprintf( pFile, "OUTPUT(%s)\n", Abc_ObjName(Abc_ObjFanin0(pNode)) );
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachLatch( pNtk, pNode, i )
fprintf( pFile, "%-11s = DFF(%s)\n", fprintf( pFile, "%-11s = DFF(%s)\n",
Abc_ObjName(pNode), Abc_ObjName(Abc_ObjFanin0(pNode)) ); Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode))), Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pNode))) );
// write internal nodes // write internal nodes
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
......
...@@ -379,8 +379,8 @@ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch ) ...@@ -379,8 +379,8 @@ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch )
{ {
Abc_Obj_t * pNetLi, * pNetLo; Abc_Obj_t * pNetLi, * pNetLo;
int Reset; int Reset;
pNetLi = Abc_ObjFanin0( pLatch ); pNetLi = Abc_ObjFanin0( Abc_ObjFanin0(pLatch) );
pNetLo = Abc_ObjFanout0( pLatch ); pNetLo = Abc_ObjFanout0( Abc_ObjFanout0(pLatch) );
Reset = (int)Abc_ObjData( pLatch ); Reset = (int)Abc_ObjData( pLatch );
// write the latch line // write the latch line
fprintf( pFile, ".latch" ); fprintf( pFile, ".latch" );
......
...@@ -331,7 +331,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -331,7 +331,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
} }
Abc_NtkForEachLatch( pNtk, pTerm, i ) Abc_NtkForEachLatch( pNtk, pTerm, i )
{ {
pNet = Abc_ObjFanin0(pTerm); pNet = Abc_ObjFanin0(Abc_ObjFanin0(pTerm));
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Abc_ObjName(pNet)) + 2; AddedLength = strlen(Abc_ObjName(pNet)) + 2;
...@@ -377,7 +377,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -377,7 +377,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
NameCounter = 0; NameCounter = 0;
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
{ {
pNet = Abc_ObjFanout0(pLatch); pNet = Abc_ObjFanout0(Abc_ObjFanout0(pLatch));
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Abc_ObjName(pNet)) + 2; AddedLength = strlen(Abc_ObjName(pNet)) + 2;
...@@ -412,14 +412,14 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -412,14 +412,14 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk )
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
{ {
// fprintf( pFile, " always@(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); // fprintf( pFile, " always@(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " always begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); fprintf( pFile, " always begin %s", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
fprintf( pFile, " = %s; end\n", Abc_ObjName(Abc_ObjFanin0(pLatch)) ); fprintf( pFile, " = %s; end\n", Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) );
if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO ) if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO )
// fprintf( pFile, " initial begin %s = 1\'b0; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); // fprintf( pFile, " initial begin %s = 1\'b0; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " initial begin %s = 0; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); fprintf( pFile, " initial begin %s = 0; end\n", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE ) else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE )
// fprintf( pFile, " initial begin %s = 1\'b1; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); // fprintf( pFile, " initial begin %s = 1\'b1; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " initial begin %s = 1; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); fprintf( pFile, " initial begin %s = 1; end\n", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
} }
} }
...@@ -431,11 +431,11 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -431,11 +431,11 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk )
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
{ {
if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO ) if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO )
fprintf( pFile, " initial begin %s <= 1\'b0; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); fprintf( pFile, " initial begin %s <= 1\'b0; end\n", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE ) else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE )
fprintf( pFile, " initial begin %s <= 1\'b1; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); fprintf( pFile, " initial begin %s <= 1\'b1; end\n", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
fprintf( pFile, " always@(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) ); fprintf( pFile, " always@(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
fprintf( pFile, " <= %s; end\n", Abc_ObjName(Abc_ObjFanin0(pLatch)) ); fprintf( pFile, " <= %s; end\n", Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) );
} }
} }
*/ */
......
...@@ -116,19 +116,19 @@ Abc_Ntk_t * Abc_NtkAigToSeq( Abc_Ntk_t * pNtk ) ...@@ -116,19 +116,19 @@ Abc_Ntk_t * Abc_NtkAigToSeq( Abc_Ntk_t * pNtk )
{ {
Vec_PtrPush( pNtkNew->vPis, pObj->pCopy ); Vec_PtrPush( pNtkNew->vPis, pObj->pCopy );
Vec_PtrPush( pNtkNew->vCis, pObj->pCopy ); Vec_PtrPush( pNtkNew->vCis, pObj->pCopy );
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
} }
Abc_NtkForEachPo( pNtk, pObj, i ) Abc_NtkForEachPo( pNtk, pObj, i )
{ {
Vec_PtrPush( pNtkNew->vPos, pObj->pCopy ); Vec_PtrPush( pNtkNew->vPos, pObj->pCopy );
Vec_PtrPush( pNtkNew->vCos, pObj->pCopy ); Vec_PtrPush( pNtkNew->vCos, pObj->pCopy );
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
} }
Abc_NtkForEachAssert( pNtk, pObj, i ) Abc_NtkForEachAssert( pNtk, pObj, i )
{ {
Vec_PtrPush( pNtkNew->vAsserts, pObj->pCopy ); Vec_PtrPush( pNtkNew->vAsserts, pObj->pCopy );
Vec_PtrPush( pNtkNew->vCos, pObj->pCopy ); Vec_PtrPush( pNtkNew->vCos, pObj->pCopy );
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
} }
// relink the choice nodes // relink the choice nodes
...@@ -268,7 +268,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk ) ...@@ -268,7 +268,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
// duplicate the nodes // duplicate the nodes
Abc_AigForEachAnd( pNtk, pObj, i ) Abc_AigForEachAnd( pNtk, pObj, i )
{ {
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj, 0);
pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) ); pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
} }
// share and create the latches // share and create the latches
...@@ -302,7 +302,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk ) ...@@ -302,7 +302,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
Seq_NtkShareLatchesClean( pNtk ); Seq_NtkShareLatchesClean( pNtk );
// add the latches and their names // add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkNew ); Abc_NtkAddDummyBoxNames( pNtkNew );
Abc_NtkOrderCisCos( pNtkNew ); Abc_NtkOrderCisCos( pNtkNew );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 ); Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
...@@ -340,7 +340,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk ) ...@@ -340,7 +340,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk )
if ( Abc_ObjFaninNum(pObj) == 0 ) if ( Abc_ObjFaninNum(pObj) == 0 )
continue; continue;
// duplicate the node // duplicate the node
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj, 0);
if ( Abc_ObjFaninNum(pObj) == 1 ) if ( Abc_ObjFaninNum(pObj) == 1 )
{ {
assert( !Abc_ObjFaninC0(pObj) ); assert( !Abc_ObjFaninC0(pObj) );
...@@ -372,7 +372,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk ) ...@@ -372,7 +372,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk )
// the complemented edges are subsumed by the node function // the complemented edges are subsumed by the node function
} }
// add the latches and their names // add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkNew ); Abc_NtkAddDummyBoxNames( pNtkNew );
Abc_NtkOrderCisCos( pNtkNew ); Abc_NtkOrderCisCos( pNtkNew );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 ); Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
......
...@@ -126,7 +126,7 @@ Abc_Ntk_t * Seq_NtkFpgaDup( Abc_Ntk_t * pNtk ) ...@@ -126,7 +126,7 @@ Abc_Ntk_t * Seq_NtkFpgaDup( Abc_Ntk_t * pNtk )
// duplicate the nodes in the mapping // duplicate the nodes in the mapping
Vec_PtrForEachEntry( p->vMapAnds, pObj, i ) Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj ); Abc_NtkDupObj( pNtkNew, pObj, 0 );
// recursively construct the internals of each node // recursively construct the internals of each node
Vec_PtrForEachEntry( p->vMapAnds, pObj, i ) Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
...@@ -321,7 +321,7 @@ Abc_Ntk_t * Seq_NtkSeqFpgaMapped( Abc_Ntk_t * pNtk ) ...@@ -321,7 +321,7 @@ Abc_Ntk_t * Seq_NtkSeqFpgaMapped( Abc_Ntk_t * pNtk )
} }
// add the latches and their names // add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkMap ); Abc_NtkAddDummyBoxNames( pNtkMap );
Abc_NtkOrderCisCos( pNtkMap ); Abc_NtkOrderCisCos( pNtkMap );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkMap, 1 ); Abc_NtkLogicMakeSimpleCos( pNtkMap, 1 );
......
...@@ -412,7 +412,7 @@ Abc_Ntk_t * Seq_NtkSeqMapMapped( Abc_Ntk_t * pNtk ) ...@@ -412,7 +412,7 @@ Abc_Ntk_t * Seq_NtkSeqMapMapped( Abc_Ntk_t * pNtk )
} }
// add the latches and their names // add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkMap ); Abc_NtkAddDummyBoxNames( pNtkMap );
Abc_NtkOrderCisCos( pNtkMap ); Abc_NtkOrderCisCos( pNtkMap );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkMap, 1 ); Abc_NtkLogicMakeSimpleCos( pNtkMap, 1 );
......
...@@ -125,14 +125,14 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -125,14 +125,14 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose )
Abc_NtkCleanCopy( pNtk ); Abc_NtkCleanCopy( pNtk );
// clone the PIs/POs/latches // clone the PIs/POs/latches
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj ); Abc_NtkDupObj( pNtkNew, pObj, 0 );
Abc_NtkForEachPo( pNtk, pObj, i ) Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj ); Abc_NtkDupObj( pNtkNew, pObj, 0 );
// copy the names // copy the names
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
Abc_NtkForEachPo( pNtk, pObj, i ) Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) ); Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
// create one AND for each logic node in the topological order // create one AND for each logic node in the topological order
vMapAnds = Abc_NtkDfs( pNtk, 0 ); vMapAnds = Abc_NtkDfs( pNtk, 0 );
...@@ -354,7 +354,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq ) ...@@ -354,7 +354,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq )
Abc_NtkForEachNode( pNtkOld, pObj, i ) Abc_NtkForEachNode( pNtkOld, pObj, i )
{ {
if ( i == 0 ) continue; if ( i == 0 ) continue;
Abc_NtkDupObj( pNtkNew, pObj ); Abc_NtkDupObj( pNtkNew, pObj, 0 );
pObj->pNext->pCopy = pObj->pCopy; pObj->pNext->pCopy = pObj->pCopy;
} }
Abc_NtkForEachLatch( pNtkOld, pObj, i ) Abc_NtkForEachLatch( pNtkOld, pObj, i )
...@@ -407,7 +407,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq ) ...@@ -407,7 +407,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq )
Seq_NtkShareLatchesClean( pNtkSeq ); Seq_NtkShareLatchesClean( pNtkSeq );
// add the latches and their names // add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkNew ); Abc_NtkAddDummyBoxNames( pNtkNew );
Abc_NtkOrderCisCos( pNtkNew ); Abc_NtkOrderCisCos( pNtkNew );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 ); Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
......
...@@ -25,6 +25,27 @@ ...@@ -25,6 +25,27 @@
extern "C" { extern "C" {
#endif #endif
/*
This manager is designed to store ID-to-name and name-to-ID mapping
for Boolean networks and And-Inverter Graphs.
In a netlist, net names are unique. In this case, there is a one-to-one
mapping between IDs and names.
In a logic network, which do not have nets, several objects may have
the same name. For example, a latch output and a primary output.
Another example, a primary input and an input to a black box.
In this case, for each ID on an object there is only one name,
but for each name may be several IDs of objects having this name.
The name manager maps ID-to-name uniquely but it allows one name to
be mapped into several IDs. When a query to find an ID of the object
by its name is submitted, it is possible to specify the object type,
which will help select one of several IDs. If the type is -1, and
there is more than one object with the given name, any object with
the given name is returned.
*/
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// INCLUDES /// /// INCLUDES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -51,12 +72,11 @@ typedef struct Nm_Man_t_ Nm_Man_t; ...@@ -51,12 +72,11 @@ typedef struct Nm_Man_t_ Nm_Man_t;
extern Nm_Man_t * Nm_ManCreate( int nSize ); extern Nm_Man_t * Nm_ManCreate( int nSize );
extern void Nm_ManFree( Nm_Man_t * p ); extern void Nm_ManFree( Nm_Man_t * p );
extern int Nm_ManNumEntries( Nm_Man_t * p ); extern int Nm_ManNumEntries( Nm_Man_t * p );
extern char * Nm_ManStoreIdName( Nm_Man_t * p, int ObjId, char * pName, char * pSuffix ); extern char * Nm_ManStoreIdName( Nm_Man_t * p, int ObjId, int Type, char * pName, char * pSuffix );
extern void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId ); extern void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId );
extern char * Nm_ManCreateUniqueName( Nm_Man_t * p, int ObjId ); extern char * Nm_ManCreateUniqueName( Nm_Man_t * p, int ObjId );
extern char * Nm_ManFindNameById( Nm_Man_t * p, int ObjId ); extern char * Nm_ManFindNameById( Nm_Man_t * p, int ObjId );
extern int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int * pSecond ); extern int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int Type );
extern void Nm_ManPrintTables( Nm_Man_t * p );
extern Vec_Int_t * Nm_ManReturnNameIds( Nm_Man_t * p ); extern Vec_Int_t * Nm_ManReturnNameIds( Nm_Man_t * p );
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -46,7 +46,7 @@ Nm_Man_t * Nm_ManCreate( int nSize ) ...@@ -46,7 +46,7 @@ Nm_Man_t * Nm_ManCreate( int nSize )
p = ALLOC( Nm_Man_t, 1 ); p = ALLOC( Nm_Man_t, 1 );
memset( p, 0, sizeof(Nm_Man_t) ); memset( p, 0, sizeof(Nm_Man_t) );
// set the parameters // set the parameters
p->nSizeFactor = 2; // determined how much larger the table should be compared to data in it p->nSizeFactor = 2; // determined the limit on the grow of data before the table resizes
p->nGrowthFactor = 3; // determined how much the table grows after resizing p->nGrowthFactor = 3; // determined how much the table grows after resizing
// allocate and clean the bins // allocate and clean the bins
p->nBins = Cudd_PrimeNm(nSize); p->nBins = Cudd_PrimeNm(nSize);
...@@ -106,29 +106,23 @@ int Nm_ManNumEntries( Nm_Man_t * p ) ...@@ -106,29 +106,23 @@ int Nm_ManNumEntries( Nm_Man_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
char * Nm_ManStoreIdName( Nm_Man_t * p, int ObjId, char * pName, char * pSuffix ) char * Nm_ManStoreIdName( Nm_Man_t * p, int ObjId, int Type, char * pName, char * pSuffix )
{ {
Nm_Entry_t * pEntry, * pEntry2; Nm_Entry_t * pEntry;
int RetValue, nEntrySize; int RetValue, nEntrySize;
// check if the object with this ID is already stored
if ( pEntry = Nm_ManTableLookupId(p, ObjId) ) if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
{ {
if ( strcmp(pEntry->Name, pName) == 0 ) printf( "Nm_ManStoreIdName(): Entry with the same ID already exists.\n" );
printf( "Nm_ManStoreIdName(): Entry with the same ID and name already exists.\n" );
else
printf( "Nm_ManStoreIdName(): Entry with the same ID and different name already exists.\n" );
return NULL;
}
if ( pSuffix == NULL && (pEntry = Nm_ManTableLookupName(p, pName, &pEntry2)) && pEntry2 )
{
printf( "Nm_ManStoreIdName(): Two entries with the same name already exist.\n" );
return NULL; return NULL;
} }
// create the entry // create a new entry
nEntrySize = sizeof(Nm_Entry_t) + strlen(pName) + (pSuffix?strlen(pSuffix):0) + 1; nEntrySize = sizeof(Nm_Entry_t) + strlen(pName) + (pSuffix?strlen(pSuffix):0) + 1;
nEntrySize = (nEntrySize / 4 + ((nEntrySize % 4) > 0)) * 4; nEntrySize = (nEntrySize / 4 + ((nEntrySize % 4) > 0)) * 4;
pEntry = (Nm_Entry_t *)Extra_MmFlexEntryFetch( p->pMem, nEntrySize ); pEntry = (Nm_Entry_t *)Extra_MmFlexEntryFetch( p->pMem, nEntrySize );
pEntry->pNextI2N = pEntry->pNextN2I = NULL; pEntry->pNextI2N = pEntry->pNextN2I = NULL;
pEntry->ObjId = ObjId; pEntry->ObjId = ObjId;
pEntry->Type = Type;
sprintf( pEntry->Name, "%s%s", pName, pSuffix? pSuffix : "" ); sprintf( pEntry->Name, "%s%s", pName, pSuffix? pSuffix : "" );
// add the entry to the hash table // add the entry to the hash table
RetValue = Nm_ManTableAdd( p, pEntry ); RetValue = Nm_ManTableAdd( p, pEntry );
...@@ -158,7 +152,7 @@ void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId ) ...@@ -158,7 +152,7 @@ void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId )
return; return;
} }
// remove entry from the table // remove entry from the table
Nm_ManTableDelete( p, pEntry ); Nm_ManTableDelete( p, ObjId );
} }
...@@ -167,7 +161,7 @@ void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId ) ...@@ -167,7 +161,7 @@ void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId )
Synopsis [Finds a unique name for the node.] Synopsis [Finds a unique name for the node.]
Description [If the name exists, tries appending numbers to it until Description [If the name exists, tries appending numbers to it until
it becomes unique.] it becomes unique. The name is not added to the table.]
SideEffects [] SideEffects []
...@@ -182,9 +176,9 @@ char * Nm_ManCreateUniqueName( Nm_Man_t * p, int ObjId ) ...@@ -182,9 +176,9 @@ char * Nm_ManCreateUniqueName( Nm_Man_t * p, int ObjId )
if ( pEntry = Nm_ManTableLookupId(p, ObjId) ) if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
return pEntry->Name; return pEntry->Name;
sprintf( NameStr, "[%d]", ObjId ); sprintf( NameStr, "[%d]", ObjId );
for ( i = 1; Nm_ManTableLookupName(p, NameStr, NULL); i++ ) for ( i = 1; Nm_ManTableLookupName(p, NameStr, -1); i++ )
sprintf( NameStr, "[%d]_%d", ObjId, i ); sprintf( NameStr, "[%d]_%d", ObjId, i );
return Nm_ManStoreIdName( p, ObjId, NameStr, NULL ); return NameStr;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -218,69 +212,14 @@ char * Nm_ManFindNameById( Nm_Man_t * p, int ObjId ) ...@@ -218,69 +212,14 @@ char * Nm_ManFindNameById( Nm_Man_t * p, int ObjId )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int * pSecond ) int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int Type )
{ {
Nm_Entry_t * pEntry, * pEntry2; Nm_Entry_t * pEntry;
if ( pEntry = Nm_ManTableLookupName(p, pName, &pEntry2) ) if ( pEntry = Nm_ManTableLookupName(p, pName, Type) )
{
if ( pSecond )
*pSecond = pEntry2? pEntry2->ObjId : -1;
return pEntry->ObjId; return pEntry->ObjId;
}
return -1; return -1;
} }
/**Function*************************************************************
Synopsis [Prints distribution of entries in the bins.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Nm_ManPrintTables( Nm_Man_t * p )
{
int i, Counter;
// rehash the entries from the old table
Counter = 0;
printf( "Int2Name: " );
for ( i = 0; i < p->nBins; i++ )
{
if ( Counter == 0 && p->pBinsI2N[i] == NULL )
continue;
if ( p->pBinsI2N[i] )
Counter++;
else
{
printf( "%d ", Counter );
Counter = 0;
}
}
printf( "\n" );
// rehash the entries from the old table
Counter = 0;
printf( "Name2Int: " );
for ( i = 0; i < p->nBins; i++ )
{
if ( Counter == 0 && p->pBinsN2I[i] == NULL )
continue;
if ( p->pBinsN2I[i] )
Counter++;
else
{
printf( "%d ", Counter );
Counter = 0;
}
}
printf( "\n" );
}
/**Function************************************************************* /**Function*************************************************************
Synopsis [Return the IDs of objects with names.] Synopsis [Return the IDs of objects with names.]
......
...@@ -44,9 +44,11 @@ extern "C" { ...@@ -44,9 +44,11 @@ extern "C" {
typedef struct Nm_Entry_t_ Nm_Entry_t; typedef struct Nm_Entry_t_ Nm_Entry_t;
struct Nm_Entry_t_ struct Nm_Entry_t_
{ {
int ObjId; // object ID unsigned Type : 4; // object type
unsigned ObjId : 28; // object ID
Nm_Entry_t * pNextI2N; // the next entry in the ID hash table Nm_Entry_t * pNextI2N; // the next entry in the ID hash table
Nm_Entry_t * pNextN2I; // the next entry in the name hash table Nm_Entry_t * pNextN2I; // the next entry in the name hash table
Nm_Entry_t * pNameSake; // the next entry with the same name
char Name[0]; // name of the object char Name[0]; // name of the object
}; };
...@@ -71,9 +73,9 @@ struct Nm_Man_t_ ...@@ -71,9 +73,9 @@ struct Nm_Man_t_
/*=== nmTable.c ==========================================================*/ /*=== nmTable.c ==========================================================*/
extern int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry ); extern int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry );
extern int Nm_ManTableDelete( Nm_Man_t * p, Nm_Entry_t * pEntry ); extern int Nm_ManTableDelete( Nm_Man_t * p, int ObjId );
extern Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId ); extern Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId );
extern Nm_Entry_t * Nm_ManTableLookupName( Nm_Man_t * p, char * pName, Nm_Entry_t ** ppSecond ); extern Nm_Entry_t * Nm_ManTableLookupName( Nm_Man_t * p, char * pName, int Type );
extern unsigned int Cudd_PrimeNm( unsigned int p ); extern unsigned int Cudd_PrimeNm( unsigned int p );
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -67,37 +67,29 @@ static void Nm_ManResize( Nm_Man_t * p ); ...@@ -67,37 +67,29 @@ static void Nm_ManResize( Nm_Man_t * p );
***********************************************************************/ ***********************************************************************/
int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry ) int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry )
{ {
Nm_Entry_t ** ppSpot; Nm_Entry_t ** ppSpot, * pOther;
// int i;
// resize the tables if needed // resize the tables if needed
// if ( p->nEntries * p->nSizeFactor > p->nBins )
if ( p->nEntries > p->nBins * p->nSizeFactor ) if ( p->nEntries > p->nBins * p->nSizeFactor )
{
// Nm_ManPrintTables( p );
Nm_ManResize( p ); Nm_ManResize( p );
} // add the entry to the table Id->Name
/* assert( Nm_ManTableLookupId(p, pEntry->ObjId) == NULL );
// hash it by ID
for ( i = Nm_HashNumber(pEntry->ObjId, p->nBins); p->pBinsI2N[i]; i = (i+1) % p->nBins )
if ( p->pBinsI2N[i] == pEntry )
return 0;
assert( p->pBinsI2N[i] == NULL );
p->pBinsI2N[i] = pEntry;
// hash it by Name
for ( i = Nm_HashString(pEntry->Name, p->nBins); p->pBinsN2I[i]; i = (i+1) % p->nBins )
if ( p->pBinsN2I[i] == pEntry )
return 0;
assert( p->pBinsN2I[i] == NULL );
p->pBinsN2I[i] = pEntry;
*/
ppSpot = p->pBinsI2N + Nm_HashNumber(pEntry->ObjId, p->nBins); ppSpot = p->pBinsI2N + Nm_HashNumber(pEntry->ObjId, p->nBins);
pEntry->pNextI2N = *ppSpot; pEntry->pNextI2N = *ppSpot;
*ppSpot = pEntry; *ppSpot = pEntry;
// check if an entry with the same name already exists
ppSpot = p->pBinsN2I + Nm_HashString(pEntry->Name, p->nBins); if ( pOther = Nm_ManTableLookupName(p, pEntry->Name, -1) )
pEntry->pNextN2I = *ppSpot; {
*ppSpot = pEntry; // entry with the same name already exists - add it to the ring
pEntry->pNameSake = pOther->pNameSake? pOther->pNameSake : pOther;
pOther->pNameSake = pEntry;
}
else
{
// entry with the same name does not exist - add it to the table
ppSpot = p->pBinsN2I + Nm_HashString(pEntry->Name, p->nBins);
pEntry->pNextN2I = *ppSpot;
*ppSpot = pEntry;
}
// report successfully added entry // report successfully added entry
p->nEntries++; p->nEntries++;
return 1; return 1;
...@@ -114,10 +106,51 @@ int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry ) ...@@ -114,10 +106,51 @@ int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Nm_ManTableDelete( Nm_Man_t * p, Nm_Entry_t * pEntry ) int Nm_ManTableDelete( Nm_Man_t * p, int ObjId )
{ {
assert( 0 ); Nm_Entry_t ** ppSpot, * pEntry, * pPrev;
return 0; int fRemoved;
// remove the entry from the table Id->Name
assert( Nm_ManTableLookupId(p, ObjId) != NULL );
ppSpot = p->pBinsI2N + Nm_HashNumber(ObjId, p->nBins);
while ( (*ppSpot)->ObjId != (unsigned)ObjId )
ppSpot = &(*ppSpot)->pNextI2N;
pEntry = *ppSpot;
*ppSpot = (*ppSpot)->pNextI2N;
// remove the entry from the table Name->Id
ppSpot = p->pBinsN2I + Nm_HashString(pEntry->Name, p->nBins);
while ( *ppSpot && *ppSpot != pEntry )
ppSpot = &(*ppSpot)->pNextN2I;
// remember if we found this one in the list
fRemoved = (*ppSpot != NULL);
if ( *ppSpot )
{
assert( *ppSpot == pEntry );
*ppSpot = (*ppSpot)->pNextN2I;
}
// quit if this entry has no namesakes
if ( pEntry->pNameSake == NULL )
{
assert( fRemoved );
return 1;
}
// remove entry from the ring of namesakes
assert( pEntry->pNameSake != pEntry );
for ( pPrev = pEntry; pPrev->pNameSake != pEntry; pPrev = pPrev->pNameSake );
assert( !strcmp(pPrev->Name, pEntry->Name) );
assert( pPrev->pNameSake == pEntry );
if ( pEntry->pNameSake == pPrev ) // two entries in the ring
pPrev->pNameSake = NULL;
else
pPrev->pNameSake = pEntry->pNameSake;
// reinsert the ring back if we removed its connection with the list in the table
if ( fRemoved )
{
assert( pPrev->pNextN2I == NULL );
pPrev->pNextN2I = *ppSpot;
*ppSpot = pPrev;
}
return 1;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -134,21 +167,15 @@ int Nm_ManTableDelete( Nm_Man_t * p, Nm_Entry_t * pEntry ) ...@@ -134,21 +167,15 @@ int Nm_ManTableDelete( Nm_Man_t * p, Nm_Entry_t * pEntry )
Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId ) Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId )
{ {
Nm_Entry_t * pEntry; Nm_Entry_t * pEntry;
// int i;
/*
for ( i = Nm_HashNumber(ObjId, p->nBins); p->pBinsI2N[i]; i = (i+1) % p->nBins )
if ( p->pBinsI2N[i]->ObjId == ObjId )
return p->pBinsI2N[i];
*/
for ( pEntry = p->pBinsI2N[ Nm_HashNumber(ObjId, p->nBins) ]; pEntry; pEntry = pEntry->pNextI2N ) for ( pEntry = p->pBinsI2N[ Nm_HashNumber(ObjId, p->nBins) ]; pEntry; pEntry = pEntry->pNextI2N )
if ( pEntry->ObjId == ObjId ) if ( pEntry->ObjId == (unsigned)ObjId )
return pEntry; return pEntry;
return NULL; return NULL;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Looks up the entry by name. May return two entries.] Synopsis [Looks up the entry by name and type.]
Description [] Description []
...@@ -157,42 +184,14 @@ Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId ) ...@@ -157,42 +184,14 @@ Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Nm_Entry_t * Nm_ManTableLookupName( Nm_Man_t * p, char * pName, Nm_Entry_t ** ppSecond ) Nm_Entry_t * Nm_ManTableLookupName( Nm_Man_t * p, char * pName, int Type )
{ {
Nm_Entry_t * pFirst, * pSecond, * pEntry; Nm_Entry_t * pEntry;
int Counter = 0; int Counter = 0;
pFirst = pSecond = NULL;
/*
for ( i = Nm_HashString(pName, p->nBins); p->pBinsN2I[i]; i = (i+1) % p->nBins )
if ( strcmp(p->pBinsN2I[i]->Name, pName) == 0 )
{
if ( pFirst == NULL )
pFirst = p->pBinsN2I[i];
else if ( pSecond == NULL )
pSecond = p->pBinsN2I[i];
else
assert( 0 ); // name appears more than 2 times
}
else
Counter++;
if ( Counter > 100 )
printf( "%d ", Counter );
*/
for ( pEntry = p->pBinsN2I[ Nm_HashString(pName, p->nBins) ]; pEntry; pEntry = pEntry->pNextN2I ) for ( pEntry = p->pBinsN2I[ Nm_HashString(pName, p->nBins) ]; pEntry; pEntry = pEntry->pNextN2I )
if ( strcmp(pEntry->Name, pName) == 0 ) if ( !strcmp(pEntry->Name, pName) && (Type == -1 || pEntry->Type == (unsigned)Type) )
{ return pEntry;
if ( pFirst == NULL ) return pEntry;
pFirst = pEntry;
else if ( pSecond == NULL )
pSecond = pEntry;
else
assert( 0 ); // name appears more than 2 times
}
// save the names
if ( ppSecond )
*ppSecond = pSecond;
return pFirst;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -230,8 +229,6 @@ void Nm_ManProfile( Nm_Man_t * p ) ...@@ -230,8 +229,6 @@ void Nm_ManProfile( Nm_Man_t * p )
printf( "\n" ); printf( "\n" );
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Resizes the table.] Synopsis [Resizes the table.]
...@@ -256,39 +253,26 @@ clk = clock(); ...@@ -256,39 +253,26 @@ clk = clock();
pBinsNewN2I = ALLOC( Nm_Entry_t *, nBinsNew ); pBinsNewN2I = ALLOC( Nm_Entry_t *, nBinsNew );
memset( pBinsNewI2N, 0, sizeof(Nm_Entry_t *) * nBinsNew ); memset( pBinsNewI2N, 0, sizeof(Nm_Entry_t *) * nBinsNew );
memset( pBinsNewN2I, 0, sizeof(Nm_Entry_t *) * nBinsNew ); memset( pBinsNewN2I, 0, sizeof(Nm_Entry_t *) * nBinsNew );
// rehash the entries from the old table // rehash entries in Id->Name table
Counter = 0; Counter = 0;
for ( e = 0; e < p->nBins; e++ ) for ( e = 0; e < p->nBins; e++ )
for ( pEntry = p->pBinsI2N[e], pEntry2 = pEntry? pEntry->pNextI2N : NULL; for ( pEntry = p->pBinsI2N[e], pEntry2 = pEntry? pEntry->pNextI2N : NULL;
pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNextI2N : NULL ) pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNextI2N : NULL )
{ {
// pEntry = p->pBinsI2N[e]; ppSpot = pBinsNewI2N + Nm_HashNumber(pEntry->ObjId, nBinsNew);
// if ( pEntry == NULL ) pEntry->pNextI2N = *ppSpot;
// continue; *ppSpot = pEntry;
/* Counter++;
// hash it by ID }
for ( i = Nm_HashNumber(pEntry->ObjId, nBinsNew); pBinsNewI2N[i]; i = (i+1) % nBinsNew ) // rehash entries in Name->Id table
if ( pBinsNewI2N[i] == pEntry ) for ( e = 0; e < p->nBins; e++ )
assert( 0 ); for ( pEntry = p->pBinsN2I[e], pEntry2 = pEntry? pEntry->pNextN2I : NULL;
assert( pBinsNewI2N[i] == NULL ); pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNextN2I : NULL )
pBinsNewI2N[i] = pEntry; {
// hash it by Name ppSpot = pBinsNewN2I + Nm_HashString(pEntry->Name, nBinsNew);
for ( i = Nm_HashString(pEntry->Name, nBinsNew); pBinsNewN2I[i]; i = (i+1) % nBinsNew ) pEntry->pNextN2I = *ppSpot;
if ( pBinsNewN2I[i] == pEntry ) *ppSpot = pEntry;
assert( 0 ); }
assert( pBinsNewN2I[i] == NULL );
pBinsNewN2I[i] = pEntry;
*/
ppSpot = pBinsNewI2N + Nm_HashNumber(pEntry->ObjId, nBinsNew);
pEntry->pNextI2N = *ppSpot;
*ppSpot = pEntry;
ppSpot = pBinsNewN2I + Nm_HashString(pEntry->Name, nBinsNew);
pEntry->pNextN2I = *ppSpot;
*ppSpot = pEntry;
Counter++;
}
assert( Counter == p->nEntries ); assert( Counter == p->nEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", p->nBins, nBinsNew ); // printf( "Increasing the structural table size from %6d to %6d. ", p->nBins, nBinsNew );
// PRT( "Time", clock() - clk ); // PRT( "Time", clock() - clk );
......
...@@ -304,9 +304,9 @@ void ABC_Network_Finalize( ABC_Manager mng ) ...@@ -304,9 +304,9 @@ void ABC_Network_Finalize( ABC_Manager mng )
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
Abc_NtkLogicStoreName( pObj, ABC_GetNodeName(mng, pObj) ); Abc_ObjAssignName( pObj, ABC_GetNodeName(mng, pObj), NULL );
Abc_NtkForEachPo( pNtk, pObj, i ) Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkLogicStoreName( pObj, ABC_GetNodeName(mng, pObj) ); Abc_ObjAssignName( pObj, ABC_GetNodeName(mng, pObj), NULL );
assert( Abc_NtkLatchNum(pNtk) == 0 ); assert( Abc_NtkLatchNum(pNtk) == 0 );
} }
......
...@@ -752,7 +752,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) ...@@ -752,7 +752,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
if ( Abc_NtkIsNetlist(pNtkGate) ) if ( Abc_NtkIsNetlist(pNtkGate) )
pNetFormal = Abc_NtkFindNet( pNtkGate, pWord ); pNetFormal = Abc_NtkFindNet( pNtkGate, pWord );
else // if ( Abc_NtkIsStrash(pNtkGate) ) else // if ( Abc_NtkIsStrash(pNtkGate) )
pNetFormal = Abc_NtkFindTerm( pNtkGate, pWord ); assert( 0 );
if ( pNetFormal == NULL ) if ( pNetFormal == NULL )
{ {
sprintf( pMan->sError, "Formal net is missing in gate %s.", pWord ); sprintf( pMan->sError, "Formal net is missing in gate %s.", pWord );
...@@ -865,7 +865,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) ...@@ -865,7 +865,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
memset( pPolarity, 0, nBytes ); memset( pPolarity, 0, nBytes );
} }
// create box to represent this gate // create box to represent this gate
pNode = Abc_NtkCreateBox( pMan->pNtkCur ); pNode = Abc_NtkCreateBlackbox( pMan->pNtkCur );
pNode->pNext = (Abc_Obj_t *)pPolarity; pNode->pNext = (Abc_Obj_t *)pPolarity;
pNode->pData = pNtkGate; pNode->pData = pNtkGate;
// connect to fanin nets // connect to fanin nets
......
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