Commit 735bca16 by Alan Mishchenko

Version abc60824

parent 7b09d2d2
......@@ -322,14 +322,6 @@ SOURCE=.\src\base\abci\abcUnreach.c
# End 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
# End Source File
# End Group
......@@ -482,10 +474,6 @@ SOURCE=.\src\base\io\ioReadPla.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioReadVerilog.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioUtil.c
# End 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;
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
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 )
pMan->vStackReplaceNew = Vec_PtrAlloc( 100 );
// create the constant node
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;
pNtkAig->nObjCounts[ABC_OBJ_NODE]--;
// save the current network
......@@ -1329,16 +1329,16 @@ void Abc_AigSetNodePhases( Abc_Ntk_t * pNtk )
int i;
assert( Abc_NtkIsDfsOrdered(pNtk) );
Abc_AigConst1(pNtk)->fPhase = 1;
// Abc_NtkForEachCi( pNtk, pObj, i )
// pObj->fPhase = 0;
Abc_NtkForEachPi( pNtk, pObj, i )
pObj->fPhase = 0;
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_NtkForEachLatchOutput( pNtk, pObj, i )
pObj->fPhase = Abc_LatchIsInit1(pObj);
Abc_AigForEachAnd( pNtk, pObj, i )
pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj)) & (Abc_ObjFanin1(pObj)->fPhase ^ Abc_ObjFaninC1(pObj));
Abc_NtkForEachPo( pNtk, pObj, i )
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 )
return 0;
}
}
/*
// check CI/CO numbers
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, "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;
}
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, "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;
}
*/
// check the names
if ( !Abc_NtkCheckNames( pNtk ) )
return 0;
......@@ -241,36 +241,36 @@ bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk )
char * pName;
int i, NameId;
// check that each CI/CO has a name
Abc_NtkForEachCi( pNtk, pObj, i )
if ( Abc_NtkIsNetlist(pNtk) )
{
pObj = Abc_ObjFanout0Ntk(pObj);
if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
// check that each net has a name
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 );
return 0;
if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
{
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) )
continue;
pObj = Abc_ObjFanin0Ntk(pObj);
if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
// check that each CI/CO has a name
Abc_NtkForEachCi( pNtk, pObj, i )
{
fprintf( stdout, "NetworkCheck: CO with ID %d is in the network but not in the name table.\n", pObj->Id );
return 0;
pObj = Abc_ObjFanout0Ntk(pObj);
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;
}
}
}
if ( Abc_NtkIsNetlist(pNtk) )
{
Abc_NtkForEachNet( pNtk, pObj, i )
Abc_NtkForEachCo( pNtk, pObj, i )
{
pName = Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id);
if ( pObj->pData && strcmp( pName, pObj->pData ) != 0 )
pObj = Abc_ObjFanin0Ntk(pObj);
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;
}
}
......@@ -543,7 +543,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
return 0;
}
}
else if ( !Abc_NtkHasMapping(pNtk) )
else if ( !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasAig(pNtk) )
{
assert( 0 );
}
......@@ -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 )
{
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
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;
}
// make sure the latch has a reasonable return value
......@@ -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) );
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;
}
......@@ -671,24 +672,26 @@ bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
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;
int i;
assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
if ( !fComb )
return 1;
if ( Abc_NtkLatchNum(pNtk1) != Abc_NtkLatchNum(pNtk2) )
if ( Abc_NtkBoxNum(pNtk1) != Abc_NtkBoxNum(pNtk2) )
{
printf( "Networks have different number of latches.\n" );
return 0;
}
// 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",
i, Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkLatch(pNtk2,i)) );
printf( "Box #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
i, Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkBox(pNtk2,i)) );
return 0;
}
}
......@@ -710,7 +713,7 @@ bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{
Abc_NtkOrderObjsByName( pNtk1, fComb );
Abc_NtkOrderObjsByName( pNtk2, fComb );
if ( !Abc_NtkCompareLatches( pNtk1, pNtk2, fComb ) )
if ( !Abc_NtkCompareBoxes( pNtk1, pNtk2, fComb ) )
return 0;
if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
return 0;
......
......@@ -45,10 +45,10 @@ bool Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot )
assert( Abc_ObjIsLatch(pLatch) );
if ( pLatch == pLatchRoot )
return 1;
pFanin = Abc_ObjFanin0(pLatch);
if ( !Abc_ObjIsLatch(pFanin) )
pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
if ( !Abc_ObjIsBi(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
return 0;
return Abc_NtkLatchIsSelfFeed_rec( pFanin, pLatch );
return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
}
/**Function*************************************************************
......@@ -66,10 +66,10 @@ bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch )
{
Abc_Obj_t * pFanin;
assert( Abc_ObjIsLatch(pLatch) );
pFanin = Abc_ObjFanin0(pLatch);
if ( !Abc_ObjIsLatch(pFanin) )
pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
if ( !Abc_ObjIsBi(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
return 0;
return Abc_NtkLatchIsSelfFeed_rec( pFanin, pLatch );
return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
}
/**Function*************************************************************
......@@ -121,7 +121,7 @@ int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk )
pConst1 = Abc_AigConst1(pNtk);
else
pConst1 = Abc_NodeCreateConst1(pNtk);
Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(pLatch), pConst1 );
Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
Counter++;
}
}
......@@ -160,7 +160,7 @@ void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches )
Abc_ObjAddFanin( pLatch, pFanin );
Abc_LatchSetInitDc( pLatch );
// 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
Vec_PtrForEachEntry( vNodes, pFanout, k )
......
......@@ -125,6 +125,7 @@ Abc_Ntk_t * Abc_LibDeriveRoot( Abc_Lib_t * pLib )
***********************************************************************/
int Abc_LibDeriveBlackBoxes( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
{
/*
Abc_Obj_t * pObj, * pFanin, * pFanout;
int i, k;
assert( Abc_NtkIsNetlist(pNtk) );
......@@ -161,6 +162,8 @@ int Abc_LibDeriveBlackBoxes( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
}
}
return Vec_PtrSize(pNtk->vBoxes);
*/
return 1;
}
/**Function*************************************************************
......
......@@ -60,7 +60,7 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc );
// duplicate the nodes
Abc_NtkForEachNode( pNtk, pObj, i )
Abc_NtkDupObj(pNtkNew, pObj);
Abc_NtkDupObj(pNtkNew, pObj, 0);
// reconnect the internal nodes in the new network
Abc_NtkForEachNode( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k )
......@@ -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
Abc_NtkForEachCi( pNtk, pObj, i )
{
Abc_ObjFanout0(pObj)->pCopy = Abc_NtkDupObj(pNtkNew, pObj);
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0(pObj)) );
Abc_ObjFanout0(pObj)->pCopy = Abc_NtkDupObj(pNtkNew, pObj, 0);
Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0(pObj)), NULL );
}
Abc_NtkForEachPo( pNtk, pObj, i )
{
Abc_NtkDupObj(pNtkNew, pObj);
Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0(pObj)) );
Abc_NtkDupObj(pNtkNew, pObj, 0);
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
Abc_NtkNetlistToLogicHie_rec( pNtkNew, pNtk, &Counter );
......@@ -164,7 +164,7 @@ void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int
if ( Abc_ObjIsNode(pNode) )
{
// 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;
continue;
}
......@@ -184,14 +184,14 @@ void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int
{
pObj->pCopy = Abc_NtkCreatePi( pNtkNew );
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
Abc_NtkForEachPi( pNtkModel, pObj, k )
{
pObj->pCopy = Abc_NtkCreatePo( pNtkNew );
// 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)++;
Vec_IntPush( pNtkNew->pBlackBoxes, (Abc_NtkPiNum(pNtkNew) << 16) | Abc_NtkPoNum(pNtkNew) );
......@@ -319,12 +319,10 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
{
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin;
char * pNameCo;
int i, k;
assert( Abc_NtkIsLogic(pNtk) );
assert( Abc_NtkLogicHasSimpleCos(pNtk) );
if ( Abc_NtkIsBddLogic(pNtk) )
{
if ( !Abc_NtkBddToSop(pNtk,0) )
......@@ -333,22 +331,19 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
// start the netlist by creating PI/PO/Latch objects
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc );
// create the CI nets and remember them in the new CI nodes
Abc_NtkForEachCi( pNtk, pObj, i )
{
pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
Abc_ObjAddFanin( pNet, pObj->pCopy );
pObj->pCopy->pCopy = pNet;
//printf( "%s ", Abc_ObjName(pObj) );
}
//printf( "\n" );
// duplicate all nodes
Abc_NtkForEachNode( pNtk, pObj, i )
{
if ( Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
continue;
Abc_NtkDupObj(pNtkNew, pObj);
Abc_NtkDupObj(pNtkNew, pObj, 0);
}
// first add the nets to the CO drivers
Abc_NtkForEachCo( pNtk, pObj, i )
......@@ -361,18 +356,18 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
continue;
}
assert( Abc_ObjIsNode(pDriver) );
// the driver is a node
// get the CO name
pNameCo = Abc_ObjIsLatch(pObj)? Abc_ObjNameSuffix( pObj, "_in" ) : Abc_ObjName(pObj);
// make sure CO has a unique name
assert( Abc_NtkFindNet( pNtkNew, pNameCo ) == NULL );
// create the CO net and connect it to CO
pNet = Abc_NtkFindOrCreateNet( pNtkNew, pNameCo );
Abc_ObjAddFanin( pObj->pCopy, pNet );
// connect the CO net to the new driver and remember it in the new driver
Abc_ObjAddFanin( pNet, pDriver->pCopy );
pDriver->pCopy->pCopy = pNet;
// if the CO drive has no net, create it
if ( pDriver->pCopy->pCopy == NULL )
{
// create the CO net and connect it to CO
pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
Abc_ObjAddFanin( pObj->pCopy, pNet );
// connect the CO net to the new driver and remember it in the new driver
Abc_ObjAddFanin( pNet, pDriver->pCopy );
pDriver->pCopy->pCopy = pNet;
}
else
assert( !strcmp( Abc_ObjName(pDriver->pCopy->pCopy), Abc_ObjName(pObj) ) );
}
// create the missing nets
Abc_NtkForEachNode( pNtk, pObj, i )
......@@ -425,7 +420,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk )
// duplicate the nodes and create node functions
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) );
}
// create the choice nodes
......@@ -519,7 +514,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk )
// duplicate the nodes, create node functions, and inverters
Vec_PtrForEachEntry( vNodes, pObj, i )
{
Abc_NtkDupObj( pNtkNew, pObj );
Abc_NtkDupObj( pNtkNew, pObj, 0 );
pObj->pCopy->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, 2, NULL );
if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
pObj->pCopy->pCopy = Abc_NodeCreateInv( pNtkNew, pObj->pCopy );
......
......@@ -99,7 +99,7 @@ void Abc_ObjRecycle( Abc_Obj_t * pObj )
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;
// 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 )
Vec_PtrPush( pNtk->vCos, pObj );
break;
case ABC_OBJ_NET:
break;
case ABC_OBJ_NODE:
case ABC_OBJ_GATE:
break;
case ABC_OBJ_LATCH:
pObj->pData = (void *)ABC_INIT_NONE;
Vec_PtrPush( pNtk->vLatches, pObj );
Vec_PtrPush( pNtk->vCis, pObj );
Vec_PtrPush( pNtk->vCos, pObj );
break;
case ABC_OBJ_BOX:
case ABC_OBJ_TRI:
case ABC_OBJ_BLACKBOX:
Vec_PtrPush( pNtk->vBoxes, pObj );
break;
default:
assert(0);
......@@ -189,8 +187,8 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
pNtk->nObjCounts[pObj->Type]--;
pNtk->nObjs--;
// remove from the table of names
// if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
// Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) )
Nm_ManDeleteIdName(pObj->pNtk->pManName, pObj->Id);
// perform specialized operations depending on the object type
switch (pObj->Type)
{
......@@ -222,7 +220,7 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
Vec_PtrRemove( pNtk->vCos, pObj );
break;
case ABC_OBJ_NET:
pObj->pData = NULL;
case ABC_OBJ_GATE:
break;
case ABC_OBJ_NODE:
if ( Abc_NtkHasBdd(pNtk) )
......@@ -230,11 +228,9 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
pObj->pData = NULL;
break;
case ABC_OBJ_LATCH:
Vec_PtrRemove( pNtk->vLatches, pObj );
Vec_PtrRemove( pNtk->vCis, pObj );
Vec_PtrRemove( pNtk->vCos, pObj );
break;
case ABC_OBJ_BOX:
case ABC_OBJ_TRI:
case ABC_OBJ_BLACKBOX:
Vec_PtrRemove( pNtk->vBoxes, pObj );
break;
default:
assert(0);
......@@ -283,11 +279,21 @@ void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj )
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;
// 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
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 )
}
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
pObjNew->pData = pObj->pData;
......@@ -318,6 +325,33 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
/**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.]
Description []
......@@ -331,7 +365,7 @@ Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj )
{
Abc_Obj_t * pClone, * pFanin;
int i;
pClone = Abc_NtkObjAdd( pObj->pNtk, pObj->Type );
pClone = Abc_NtkCreateObj( pObj->pNtk, pObj->Type );
Abc_ObjForEachFanin( pObj, pFanin, i )
Abc_ObjAddFanin( pClone, pFanin );
return pClone;
......@@ -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 * pObj, * pDriver;
int i, Num;
// check if the node is among CIs
Abc_NtkForEachCi( pNtk, pObj, i )
{
if ( strcmp( Abc_ObjName(pObj), pName ) == 0 )
{
if ( i < Abc_NtkPiNum(pNtk) )
printf( "Node \"%s\" is a primary input.\n", pName );
else
printf( "Node \"%s\" is a latch output.\n", pName );
return NULL;
}
}
// 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;
}
}
Abc_Obj_t * pObj;
int Num;
// try to find the terminal
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 );
Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NODE );
if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num );
// find the internal node
if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' )
{
......@@ -421,7 +439,7 @@ Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName )
Abc_Obj_t * pNet;
int ObjId;
assert( Abc_NtkIsNetlist(pNtk) );
ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, NULL );
ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_NET );
if ( ObjId == -1 )
return NULL;
pNet = Abc_NtkObj( pNtk, ObjId );
......@@ -430,29 +448,55 @@ Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName )
/**Function*************************************************************
Synopsis [Returns the CI/CO terminal with the given name.]
Synopsis [Returns CI with the given name.]
Description []
SideEffects []
Description []
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 ObjId;
int Num;
assert( !Abc_NtkIsNetlist(pNtk) );
ObjId = Nm_ManFindIdByName( pNtk->pManName, pName, NULL );
if ( ObjId == -1 )
return NULL;
pNet = Abc_NtkObj( pNtk, ObjId );
return pNet;
Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_PI );
if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num );
Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BI );
if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num );
return NULL;
}
/**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.]
Description []
......@@ -469,8 +513,9 @@ Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName )
if ( pName && (pNet = Abc_NtkFindNet( pNtk, pName )) )
return pNet;
// create a new net
pNet = Abc_NtkObjAdd( pNtk, ABC_OBJ_NET );
pNet->pData = pName? Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pName, NULL ) : NULL;
pNet = Abc_NtkCreateObj( pNtk, ABC_OBJ_NET );
if ( pName )
Nm_ManStoreIdName( pNtk->pManName, pNet->Id, pNet->Type, pName, NULL );
return pNet;
}
......
......@@ -47,7 +47,7 @@ void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
int i;
if ( pNtk->nTravIds == (1<<8)-1 )
if ( pNtk->nTravIds == (1<<30)-1 )
{
pNtk->nTravIds = 0;
Abc_NtkForEachObj( pNtk, pObj, i )
......@@ -69,8 +69,8 @@ void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk )
***********************************************************************/
void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
int i;
Abc_Obj_t * pObj, * pTerm;
int i, k;
Vec_PtrClear( pNtk->vCis );
Vec_PtrClear( pNtk->vCos );
Abc_NtkForEachPi( pNtk, pObj, i )
......@@ -79,10 +79,12 @@ void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk )
Vec_PtrPush( pNtk->vCos, pObj );
Abc_NtkForEachAssert( pNtk, pObj, i )
Vec_PtrPush( pNtk->vCos, pObj );
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_NtkForEachBox( pNtk, pObj, i )
{
Vec_PtrPush( pNtk->vCis, pObj );
Vec_PtrPush( pNtk->vCos, pObj );
Abc_ObjForEachFanin( pObj, pTerm, k )
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 )
/**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
fanout. This is possible if there is only one CO with non-complemented
fanin edge pointing to this node.]
Description [Checks if the internal node can borrow a name from CO fanouts.
This is possible if all COs with non-complemented fanin edge pointing to this
node have the same name.]
SideEffects []
......@@ -447,23 +472,27 @@ void Abc_NtkCleanMarkA( Abc_Ntk_t * pNtk )
Abc_Obj_t * Abc_NodeHasUniqueCoFanout( Abc_Obj_t * pNode )
{
Abc_Obj_t * pFanout, * pFanoutCo;
int i, Counter;
int i;
if ( !Abc_ObjIsNode(pNode) )
return NULL;
Counter = 0;
pFanoutCo = NULL;
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_ObjFanin0(pFanout) == pNode );
pFanoutCo = pFanout;
Counter++;
continue;
}
if ( strcmp( Abc_ObjName(pFanoutCo), Abc_ObjName(pFanout) ) ) // they have diff names
return NULL;
}
if ( Counter == 1 )
return pFanoutCo;
return NULL;
return pFanoutCo;
}
/**Function*************************************************************
......@@ -508,7 +537,7 @@ bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk )
Description [The COs of a logic network are simple under three conditions:
(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
(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
......@@ -537,15 +566,15 @@ int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, bool fDuplicate )
continue;
}
}
else
else if ( !Abc_ObjFaninC0(pNode) )
{
// skip the case when the driver's unique CO fanout is this CO
if ( Abc_NodeHasUniqueCoFanout(pDriver) == pNode )
// skip the case when all CO fanouts of the driver have the same name
if ( Abc_NodeHasUniqueCoFanout(pDriver) )
continue;
}
if ( fDuplicate && !Abc_ObjIsCi(pDriver) )
{
pDriverNew = Abc_NtkDupObj( pNtk, pDriver );
pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
Abc_ObjForEachFanin( pDriver, pFanin, k )
Abc_ObjAddFanin( pDriverNew, pFanin );
if ( Abc_ObjFaninC0(pNode) )
......@@ -1091,11 +1120,21 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
pNode->Id = Vec_PtrSize( vObjsNew );
Vec_PtrPush( vObjsNew, pNode );
}
// put latches next
Abc_NtkForEachLatch( pNtk, pNode, i )
// put latches and their inputs/outputs next
Abc_NtkForEachBox( pNtk, pNode, i )
{
pNode->Id = Vec_PtrSize( vObjsNew );
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
vNodes = Abc_AigDfs( pNtk, 1, 0 );
......@@ -1139,6 +1178,7 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
***********************************************************************/
void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk )
{
/*
Abc_Obj_t * pLatch, * pFanin;
int i, nTFFs, nJKFFs;
nTFFs = nJKFFs = 0;
......@@ -1157,13 +1197,6 @@ void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk )
Abc_ObjFaninNum( Abc_ObjFanin1(pFanin) ) != 2 )
continue;
/*
if ( !Abc_ObjFaninC0(pLatch) ||
!Abc_ObjFaninC0( Abc_ObjFanin0(pFanin) ) ||
!Abc_ObjFaninC1( Abc_ObjFanin0(pFanin) ) )
continue;
*/
if ( (Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch ||
Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch) &&
(Abc_ObjFanin0(Abc_ObjFanin1(pFanin)) == pLatch ||
......@@ -1174,6 +1207,7 @@ void Abc_NtkDetectMatching( Abc_Ntk_t * pNtk )
}
printf( "D = %6d. T = %6d. JK = %6d. (%6.2f %%)\n",
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 )
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 )
{
fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
......@@ -7433,6 +7432,8 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
printf( "This command is not implemented\n" );
// set defaults
nFrames = 1;
fExdc = 1;
......@@ -7495,10 +7496,11 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// get the new network
if ( fImp )
pNtkRes = Abc_NtkVanImp( pNtk, nFrames, fExdc, fVerbose );
else
pNtkRes = Abc_NtkVanEijk( pNtk, nFrames, fExdc, fVerbose );
// if ( fImp )
// pNtkRes = Abc_NtkVanImp( pNtk, nFrames, fExdc, fVerbose );
// else
// pNtkRes = Abc_NtkVanEijk( pNtk, nFrames, fExdc, fVerbose );
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
fprintf( pErr, "Sequential FPGA mapping has failed.\n" );
......
......@@ -25,7 +25,6 @@
////////////////////////////////////////////////////////////////////////
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 );
////////////////////////////////////////////////////////////////////////
......@@ -59,10 +58,7 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i
}
// create the new network
if ( fDualRail )
pNtkNew = Abc_NtkFromGlobalBddsDual( pNtk );
else
pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
Abc_NtkFreeGlobalBdds( pNtk );
if ( pNtkNew == NULL )
{
......@@ -134,42 +130,6 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
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 * pNodeNew, * pTemp;
......
......@@ -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 )
{
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 )
Abc_LatchSetInitDc( pObjNew );
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
else if ( Ivy_ObjInit(pNode) == IVY_INIT_0 )
Abc_LatchSetInit0( pObjNew );
else assert( 0 );
pNode->TravId = Abc_EdgeFromNode( pObjNew );
pNode->TravId = Abc_EdgeFromNode( pFaninNew1 );
}
Abc_NtkAddDummyBoxNames( pNtk );
// rebuild the AIG
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
Ivy_ManForEachNodeVec( pMan, vLatches, pNode, i )
{
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( vNodes );
......
......@@ -84,7 +84,7 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo
Cudd_bddIthVar( pNtk->pManFunc, Vec_PtrSize(vNamesPi) );
// add the PIs corresponding to the names
Vec_PtrForEachEntry( vNamesPi, pName, i )
Abc_NtkLogicStoreName( Abc_NtkCreatePi(pNtk), pName );
Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), pName, NULL );
// create the node
pNode = Abc_NtkCreateNode( pNtk );
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
// create the only PO
pNodePo = Abc_NtkCreatePo( pNtk );
Abc_ObjAddFanin( pNodePo, pNode );
Abc_NtkLogicStoreName( pNodePo, pNamePo );
Abc_ObjAssignName( pNodePo, pNamePo, NULL );
// make the network minimum base
Abc_NtkMinimumBase( pNtk );
if ( vNamesPiFake )
......@@ -246,7 +246,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
{
ProgressBar * pProgress;
Vec_Ptr_t * vFuncsGlob;
Abc_Obj_t * pNode, * pFanin;
Abc_Obj_t * pObj, * pFanin;
DdNode * bFunc;
DdManager * dd;
int i, k, Counter;
......@@ -264,17 +264,17 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
// clean storage for local BDDs
Abc_NtkCleanCopy( pNtk );
// set the elementary variables
Abc_NtkForEachCi( pNtk, pNode, i )
if ( Abc_ObjFanoutNum(pNode) > 0 )
Abc_NtkForEachCi( pNtk, pObj, i )
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] );
}
// assign the constant node BDD
pNode = Abc_AigConst1(pNtk);
if ( Abc_ObjFanoutNum(pNode) > 0 )
pObj = Abc_AigConst1(pNtk);
if ( Abc_ObjFanoutNum(pObj) > 0 )
{
pNode->pCopy = (Abc_Obj_t *)dd->one;
pObj->pCopy = (Abc_Obj_t *)dd->one;
Cudd_Ref( dd->one );
}
......@@ -285,9 +285,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
{
// construct the BDDs
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 ( fVerbose )
......@@ -296,7 +296,7 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
Cudd_Quit( dd );
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 );
}
Extra_ProgressBarStop( pProgress );
......@@ -305,9 +305,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
{
// construct the BDDs
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 ( fVerbose )
......@@ -316,34 +316,35 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
Cudd_Quit( dd );
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 );
}
Extra_ProgressBarStop( pProgress );
}
/*
// derefence the intermediate BDDs
Abc_NtkForEachNode( pNtk, pNode, i )
if ( pNode->pCopy )
Abc_NtkForEachNode( pNtk, pObj, i )
if ( pObj->pCopy )
{
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy );
pNode->pCopy = NULL;
Cudd_RecursiveDeref( dd, (DdNode *)pObj->pCopy );
pObj->pCopy = NULL;
}
*/
/*
// make sure all nodes are derefed
Abc_NtkForEachObj( pNtk, pNode, i )
Abc_NtkForEachObj( pNtk, pObj, i )
{
if ( pNode->pCopy != NULL )
printf( "Abc_NtkGlobalBdds() error: Node %d has BDD assigned\n", pNode->Id );
if ( pNode->vFanouts.nSize > 0 )
printf( "Abc_NtkGlobalBdds() error: Node %d has refs assigned\n", pNode->Id );
if ( pObj->pCopy != NULL )
printf( "Abc_NtkGlobalBdds() error: Node %d has BDD assigned\n", pObj->Id );
if ( pObj->vFanouts.nSize > 0 )
printf( "Abc_NtkGlobalBdds() error: Node %d has refs assigned\n", pObj->Id );
}
*/
// reset references
Abc_NtkForEachObj( pNtk, pNode, i )
Abc_ObjForEachFanin( pNode, pFanin, k )
pFanin->vFanouts.nSize++;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBi(pObj) )
Abc_ObjForEachFanin( pObj, pFanin, k )
pFanin->vFanouts.nSize++;
// reorder one more time
if ( fReorder )
......
......@@ -70,7 +70,7 @@ void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse,
vSupp = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
while ( fscanf( pFile, "%s", Buffer ) == 1 )
{
pObj = Abc_NtkFindTerm( pNtk, Buffer );
pObj = Abc_NtkFindCi( pNtk, Buffer );
if ( pObj == NULL || !Abc_ObjIsCi(pObj) )
{
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 )
assert( Init < 4 );
InitNums[Init]++;
pFanin = Abc_ObjFanin0(pLatch);
pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
if ( !Abc_ObjIsNode(pFanin) || !Abc_NodeIsConst(pFanin) )
continue;
......
......@@ -147,9 +147,9 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, bool fUpd
if ( fUpdateLevel )
Abc_NtkStartReverseLevels( pNtk );
if ( Abc_NtkLatchNum(pNtk) )
Abc_NtkForEachLatch(pNtk, pNode, i)
pNode->pNext = pNode->pData;
// if ( Abc_NtkLatchNum(pNtk) )
// Abc_NtkForEachLatch(pNtk, pNode, i)
// pNode->pNext = pNode->pData;
// resynthesize each node once
nNodes = Abc_NtkObjNumMax(pNtk);
......@@ -221,9 +221,9 @@ pManRes->timeTotal = clock() - clkStart;
Abc_NtkForEachObj( pNtk, pNode, i )
pNode->pData = NULL;
if ( Abc_NtkLatchNum(pNtk) )
Abc_NtkForEachLatch(pNtk, pNode, i)
pNode->pData = pNode->pNext, pNode->pNext = NULL;
// if ( Abc_NtkLatchNum(pNtk) )
// Abc_NtkForEachLatch(pNtk, pNode, i)
// pNode->pData = pNode->pNext, pNode->pNext = NULL;
// put the nodes into the DFS order and reassign their IDs
Abc_NtkReassignIds( pNtk );
......
......@@ -106,8 +106,8 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
p->nNodesOld = Abc_NtkNodeNum(pNtk);
p->nLevelsOld = Abc_AigGetLevelNum(pNtk);
// remember latch values
Abc_NtkForEachLatch( pNtk, pNode, i )
pNode->pNext = pNode->pData;
// Abc_NtkForEachLatch( pNtk, pNode, i )
// pNode->pNext = pNode->pData;
// go through the nodes
Abc_NtkCleanCopy(pNtk);
nNodes = Abc_NtkObjNumMax(pNtk);
......@@ -216,8 +216,8 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
Abc_RRManPrintStats( p );
Abc_RRManStop( p );
// restore latch values
Abc_NtkForEachLatch( pNtk, pNode, i )
pNode->pData = pNode->pNext, pNode->pNext = NULL;
// Abc_NtkForEachLatch( pNtk, pNode, i )
// pNode->pData = pNode->pNext, pNode->pNext = NULL;
// put the nodes into the DFS order and reassign their IDs
Abc_NtkReassignIds( pNtk );
Abc_NtkGetLevelNum( pNtk );
......
......@@ -327,7 +327,7 @@ Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels )
pPoNew = Abc_NtkCreatePo(pNtkNew);
Abc_ObjAddFanin( pPoNew, pObjNew );
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
if ( !Abc_NtkCheck( pNtkNew ) )
{
......
......@@ -59,11 +59,31 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose )
Abc_Ntk_t * pNtkAig;
Fraig_Man_t * pMan;
stmm_table * tEquiv;
Abc_Obj_t * pObj;
int i, fUseTrick;
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
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
Fraig_ParamsSetDefault( &Params );
......@@ -176,8 +196,8 @@ stmm_table * Abc_NtkFraigEquiv( Abc_Ntk_t * pNtk, int fUseInv, bool fVerbose )
// skip the dangling nodes
if ( pNodeAig == NULL )
continue;
// skip the nodes that fanout into POs
if ( Abc_NodeHasUniqueCoFanout(pNode) )
// skip the nodes that fanout into COs
if ( Abc_NodeHasCoFanout(pNode) )
continue;
// get the FRAIG node
gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, Abc_ObjIsComplement(pNodeAig) );
......
......@@ -254,9 +254,9 @@ void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk )
continue;
*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;
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_NtkForEachLatchOutput( pNtk, pObj, i )
{
pTime = ppTimes[pObj->Id];
pTime->Fall = pTime->Rise = pTime->Worst = 0.0;
......
......@@ -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 * pNtkNew;
Abc_Obj_t * pNode, * pNodeNew;
int * pPermute;
......@@ -290,7 +291,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
// create PIs corresponding to LOs
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
// create a new node
......@@ -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)
Abc_NtkForEachPo( pNtk, pNode, i )
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_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
Abc_NtkForEachPo( pNtk, pNode, i )
......@@ -337,6 +338,8 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
return NULL;
}
return pNtkNew;
*/
return NULL;
}
////////////////////////////////////////////////////////////////////////
......
......@@ -544,7 +544,7 @@ void Abc_NtkGetSeqPoSupp( Abc_Ntk_t * pNtk, int iFrame, int iNumPo )
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = NULL;
Abc_NtkForEachLatch( pNtk, pObj, i )
if ( Abc_NtkLatch(pFrames, i)->pCopy )
if ( Abc_NtkBox(pFrames, i)->pCopy )
pObj->pCopy = (void *)1;
Abc_NtkForEachPi( pNtk, pObj, i )
for ( k = 0; k <= iFrame; k++ )
......
......@@ -33,6 +33,4 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcTiming.c \
src/base/abci/abcUnate.c \
src/base/abci/abcUnreach.c \
src/base/abci/abcVanEijk.c \
src/base/abci/abcVanImp.c \
src/base/abci/abcVerify.c
......@@ -595,6 +595,9 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
int fCheck;
int c;
printf( "Stand-alone structural Verilog reader is now available as command \"read_ver\".\n" );
return 0;
fCheck = 1;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
......@@ -629,7 +632,8 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
fclose( pFile );
// set the new network
pNtk = Io_ReadVerilog( FileName, fCheck );
// pNtk = Io_ReadVerilog( FileName, fCheck );
pNtk = NULL;
if ( pNtk == NULL )
{
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 )
if ( Extra_FileNameCheckExtension( pFileName, "blif" ) )
pNtk = Io_ReadBlif( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "v" ) )
pNtk = Io_ReadVerilog( pFileName, fCheck );
pNtk = NULL; //Io_ReadVerilog( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "bench" ) )
pNtk = Io_ReadBench( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "edf" ) )
......
......@@ -85,21 +85,30 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
for ( i = 0; i < nInputs; i++ )
{
pObj = Abc_NtkCreatePi(pNtkNew);
Abc_NtkLogicStoreName( pObj, pCur ); while ( *pCur++ );
Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
Vec_PtrPush( vNodes, pObj );
}
// create the POs
for ( i = 0; i < nOutputs; i++ )
{
pObj = Abc_NtkCreatePo(pNtkNew);
Abc_NtkLogicStoreName( pObj, pCur ); while ( *pCur++ );
Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
}
// create the latches
for ( i = 0; i < nLatches; i++ )
{
pObj = Abc_NtkCreateLatch(pNtkNew);
Abc_NtkLogicStoreName( pObj, pCur ); while ( *pCur++ );
Vec_PtrPush( vNodes, pObj );
Abc_ObjAssignName( pObj, pCur, NULL ); while ( *pCur++ );
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
......@@ -129,9 +138,9 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
Abc_NtkForEachCo( pNtkNew, pObj, 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;
}
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 )
Vec_PtrPush( vNames, Extra_UtilStrsav(pName) ); // memory leak!!!
// 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
Abc_ObjSetData( pBox, vNames );
// remember the line of the file
......
......@@ -46,6 +46,9 @@ Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck )
Extra_FileReader_t * p;
Abc_Ntk_t * pNtk;
printf( "Currently this parser does not work!\n" );
return NULL;
// start the file
p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t()" );
if ( p == NULL )
......
......@@ -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 * pLatch, * pNet;
// create a new latch and add it to the network
pLatch = Abc_NtkCreateLatch( pNtk );
Abc_Obj_t * pLatch, * pTerm, * pNet;
// get the LI net
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
pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO );
Abc_ObjAddFanin( pNet, pLatch );
Abc_ObjAddFanin( pNet, pTerm );
// set latch name
Abc_ObjAssignName( pLatch, pNetLO, "_latch" );
return pLatch;
}
......
......@@ -116,7 +116,11 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
fprintf( pFile, "%s%c", Abc_ObjName(pObj), 0 );
// write latches
Abc_NtkForEachLatch( pNtk, pObj, i )
{
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
Abc_NtkCleanCopy( pNtk );
......@@ -143,8 +147,8 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
{
Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
pBufferNode[nAnds] = (((int)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj);
if ( Abc_ObjIsLatch(pObj) )
pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((unsigned)Abc_ObjData(pObj) & 3);
if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((unsigned)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3);
nAnds++;
}
Extra_ProgressBarStop( pProgress );
......
......@@ -89,7 +89,7 @@ int Io_WriteBenchOne( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, "OUTPUT(%s)\n", Abc_ObjName(Abc_ObjFanin0(pNode)) );
Abc_NtkForEachLatch( pNtk, pNode, i )
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
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
......
......@@ -379,8 +379,8 @@ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch )
{
Abc_Obj_t * pNetLi, * pNetLo;
int Reset;
pNetLi = Abc_ObjFanin0( pLatch );
pNetLo = Abc_ObjFanout0( pLatch );
pNetLi = Abc_ObjFanin0( Abc_ObjFanin0(pLatch) );
pNetLo = Abc_ObjFanout0( Abc_ObjFanout0(pLatch) );
Reset = (int)Abc_ObjData( pLatch );
// write the latch line
fprintf( pFile, ".latch" );
......
......@@ -331,7 +331,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
}
Abc_NtkForEachLatch( pNtk, pTerm, i )
{
pNet = Abc_ObjFanin0(pTerm);
pNet = Abc_ObjFanin0(Abc_ObjFanin0(pTerm));
Counter++;
// get the line length after this name is written
AddedLength = strlen(Abc_ObjName(pNet)) + 2;
......@@ -377,7 +377,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
NameCounter = 0;
Abc_NtkForEachLatch( pNtk, pLatch, i )
{
pNet = Abc_ObjFanout0(pLatch);
pNet = Abc_ObjFanout0(Abc_ObjFanout0(pLatch));
Counter++;
// get the line length after this name is written
AddedLength = strlen(Abc_ObjName(pNet)) + 2;
......@@ -412,14 +412,14 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk )
Abc_NtkForEachLatch( pNtk, pLatch, i )
{
// fprintf( pFile, " always@(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " always begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " = %s; end\n", Abc_ObjName(Abc_ObjFanin0(pLatch)) );
fprintf( pFile, " always begin %s", Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
fprintf( pFile, " = %s; end\n", Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) );
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 = 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 )
// 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 )
Abc_NtkForEachLatch( pNtk, pLatch, i )
{
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 )
fprintf( pFile, " initial begin %s <= 1\'b1; end\n", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " always@(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " <= %s; end\n", Abc_ObjName(Abc_ObjFanin0(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(Abc_ObjFanout0(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 )
{
Vec_PtrPush( pNtkNew->vPis, 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 )
{
Vec_PtrPush( pNtkNew->vPos, 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 )
{
Vec_PtrPush( pNtkNew->vAsserts, 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
......@@ -268,7 +268,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
// duplicate the nodes
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) );
}
// share and create the latches
......@@ -302,7 +302,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
Seq_NtkShareLatchesClean( pNtk );
// add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkNew );
Abc_NtkAddDummyBoxNames( pNtkNew );
Abc_NtkOrderCisCos( pNtkNew );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
......@@ -340,7 +340,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk )
if ( Abc_ObjFaninNum(pObj) == 0 )
continue;
// duplicate the node
Abc_NtkDupObj(pNtkNew, pObj);
Abc_NtkDupObj(pNtkNew, pObj, 0);
if ( Abc_ObjFaninNum(pObj) == 1 )
{
assert( !Abc_ObjFaninC0(pObj) );
......@@ -372,7 +372,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk )
// the complemented edges are subsumed by the node function
}
// add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkNew );
Abc_NtkAddDummyBoxNames( pNtkNew );
Abc_NtkOrderCisCos( pNtkNew );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
......
......@@ -126,7 +126,7 @@ Abc_Ntk_t * Seq_NtkFpgaDup( Abc_Ntk_t * pNtk )
// duplicate the nodes in the mapping
Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj );
Abc_NtkDupObj( pNtkNew, pObj, 0 );
// recursively construct the internals of each node
Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
......@@ -321,7 +321,7 @@ Abc_Ntk_t * Seq_NtkSeqFpgaMapped( Abc_Ntk_t * pNtk )
}
// add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkMap );
Abc_NtkAddDummyBoxNames( pNtkMap );
Abc_NtkOrderCisCos( pNtkMap );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkMap, 1 );
......
......@@ -412,7 +412,7 @@ Abc_Ntk_t * Seq_NtkSeqMapMapped( Abc_Ntk_t * pNtk )
}
// add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkMap );
Abc_NtkAddDummyBoxNames( pNtkMap );
Abc_NtkOrderCisCos( pNtkMap );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkMap, 1 );
......
......@@ -125,14 +125,14 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose )
Abc_NtkCleanCopy( pNtk );
// clone the PIs/POs/latches
Abc_NtkForEachPi( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj );
Abc_NtkDupObj( pNtkNew, pObj, 0 );
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj );
Abc_NtkDupObj( pNtkNew, pObj, 0 );
// copy the names
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_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
vMapAnds = Abc_NtkDfs( pNtk, 0 );
......@@ -354,7 +354,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq )
Abc_NtkForEachNode( pNtkOld, pObj, i )
{
if ( i == 0 ) continue;
Abc_NtkDupObj( pNtkNew, pObj );
Abc_NtkDupObj( pNtkNew, pObj, 0 );
pObj->pNext->pCopy = pObj->pCopy;
}
Abc_NtkForEachLatch( pNtkOld, pObj, i )
......@@ -407,7 +407,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq )
Seq_NtkShareLatchesClean( pNtkSeq );
// add the latches and their names
Abc_NtkAddDummyLatchNames( pNtkNew );
Abc_NtkAddDummyBoxNames( pNtkNew );
Abc_NtkOrderCisCos( pNtkNew );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
......
......@@ -25,6 +25,27 @@
extern "C" {
#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 ///
////////////////////////////////////////////////////////////////////////
......@@ -51,12 +72,11 @@ typedef struct Nm_Man_t_ Nm_Man_t;
extern Nm_Man_t * Nm_ManCreate( int nSize );
extern void Nm_ManFree( 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 char * Nm_ManCreateUniqueName( 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 void Nm_ManPrintTables( Nm_Man_t * p );
extern int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int Type );
extern Vec_Int_t * Nm_ManReturnNameIds( Nm_Man_t * p );
#ifdef __cplusplus
......
......@@ -46,7 +46,7 @@ Nm_Man_t * Nm_ManCreate( int nSize )
p = ALLOC( Nm_Man_t, 1 );
memset( p, 0, sizeof(Nm_Man_t) );
// 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
// allocate and clean the bins
p->nBins = Cudd_PrimeNm(nSize);
......@@ -106,29 +106,23 @@ int Nm_ManNumEntries( Nm_Man_t * p )
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;
// check if the object with this ID is already stored
if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
{
if ( strcmp(pEntry->Name, pName) == 0 )
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" );
printf( "Nm_ManStoreIdName(): Entry with the same ID already exists.\n" );
return NULL;
}
// create the entry
// create a new entry
nEntrySize = sizeof(Nm_Entry_t) + strlen(pName) + (pSuffix?strlen(pSuffix):0) + 1;
nEntrySize = (nEntrySize / 4 + ((nEntrySize % 4) > 0)) * 4;
pEntry = (Nm_Entry_t *)Extra_MmFlexEntryFetch( p->pMem, nEntrySize );
pEntry->pNextI2N = pEntry->pNextN2I = NULL;
pEntry->ObjId = ObjId;
pEntry->Type = Type;
sprintf( pEntry->Name, "%s%s", pName, pSuffix? pSuffix : "" );
// add the entry to the hash table
RetValue = Nm_ManTableAdd( p, pEntry );
......@@ -158,7 +152,7 @@ void Nm_ManDeleteIdName( Nm_Man_t * p, int ObjId )
return;
}
// 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 )
Synopsis [Finds a unique name for the node.]
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 []
......@@ -182,9 +176,9 @@ char * Nm_ManCreateUniqueName( Nm_Man_t * p, int ObjId )
if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
return pEntry->Name;
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 );
return Nm_ManStoreIdName( p, ObjId, NameStr, NULL );
return NameStr;
}
/**Function*************************************************************
......@@ -218,69 +212,14 @@ char * Nm_ManFindNameById( Nm_Man_t * p, int ObjId )
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;
if ( pEntry = Nm_ManTableLookupName(p, pName, &pEntry2) )
{
if ( pSecond )
*pSecond = pEntry2? pEntry2->ObjId : -1;
Nm_Entry_t * pEntry;
if ( pEntry = Nm_ManTableLookupName(p, pName, Type) )
return pEntry->ObjId;
}
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*************************************************************
Synopsis [Return the IDs of objects with names.]
......
......@@ -44,9 +44,11 @@ extern "C" {
typedef struct Nm_Entry_t_ 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 * 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
};
......@@ -71,9 +73,9 @@ struct Nm_Man_t_
/*=== nmTable.c ==========================================================*/
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_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 );
#ifdef __cplusplus
......
......@@ -67,37 +67,29 @@ static void Nm_ManResize( Nm_Man_t * p );
***********************************************************************/
int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry )
{
Nm_Entry_t ** ppSpot;
// int i;
Nm_Entry_t ** ppSpot, * pOther;
// resize the tables if needed
// if ( p->nEntries * p->nSizeFactor > p->nBins )
if ( p->nEntries > p->nBins * p->nSizeFactor )
{
// Nm_ManPrintTables( p );
Nm_ManResize( p );
}
/*
// 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;
*/
// add the entry to the table Id->Name
assert( Nm_ManTableLookupId(p, pEntry->ObjId) == NULL );
ppSpot = p->pBinsI2N + Nm_HashNumber(pEntry->ObjId, p->nBins);
pEntry->pNextI2N = *ppSpot;
*ppSpot = pEntry;
ppSpot = p->pBinsN2I + Nm_HashString(pEntry->Name, p->nBins);
pEntry->pNextN2I = *ppSpot;
*ppSpot = pEntry;
// check if an entry with the same name already exists
if ( pOther = Nm_ManTableLookupName(p, pEntry->Name, -1) )
{
// 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
p->nEntries++;
return 1;
......@@ -114,10 +106,51 @@ int Nm_ManTableAdd( Nm_Man_t * p, Nm_Entry_t * pEntry )
SeeAlso []
***********************************************************************/
int Nm_ManTableDelete( Nm_Man_t * p, Nm_Entry_t * pEntry )
int Nm_ManTableDelete( Nm_Man_t * p, int ObjId )
{
assert( 0 );
return 0;
Nm_Entry_t ** ppSpot, * pEntry, * pPrev;
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*************************************************************
......@@ -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 * 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 )
if ( pEntry->ObjId == ObjId )
if ( pEntry->ObjId == (unsigned)ObjId )
return pEntry;
return NULL;
}
/**Function*************************************************************
Synopsis [Looks up the entry by name. May return two entries.]
Synopsis [Looks up the entry by name and type.]
Description []
......@@ -157,42 +184,14 @@ Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId )
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;
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 )
if ( strcmp(pEntry->Name, pName) == 0 )
{
if ( pFirst == NULL )
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;
if ( !strcmp(pEntry->Name, pName) && (Type == -1 || pEntry->Type == (unsigned)Type) )
return pEntry;
return pEntry;
}
/**Function*************************************************************
......@@ -230,8 +229,6 @@ void Nm_ManProfile( Nm_Man_t * p )
printf( "\n" );
}
/**Function*************************************************************
Synopsis [Resizes the table.]
......@@ -256,39 +253,26 @@ clk = clock();
pBinsNewN2I = ALLOC( Nm_Entry_t *, nBinsNew );
memset( pBinsNewI2N, 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;
for ( e = 0; e < p->nBins; e++ )
for ( pEntry = p->pBinsI2N[e], pEntry2 = pEntry? pEntry->pNextI2N : NULL;
pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNextI2N : NULL )
{
// pEntry = p->pBinsI2N[e];
// if ( pEntry == NULL )
// continue;
/*
// hash it by ID
for ( i = Nm_HashNumber(pEntry->ObjId, nBinsNew); pBinsNewI2N[i]; i = (i+1) % nBinsNew )
if ( pBinsNewI2N[i] == pEntry )
assert( 0 );
assert( pBinsNewI2N[i] == NULL );
pBinsNewI2N[i] = pEntry;
// hash it by Name
for ( i = Nm_HashString(pEntry->Name, nBinsNew); pBinsNewN2I[i]; i = (i+1) % nBinsNew )
if ( pBinsNewN2I[i] == 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++;
}
for ( pEntry = p->pBinsI2N[e], pEntry2 = pEntry? pEntry->pNextI2N : NULL;
pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNextI2N : NULL )
{
ppSpot = pBinsNewI2N + Nm_HashNumber(pEntry->ObjId, nBinsNew);
pEntry->pNextI2N = *ppSpot;
*ppSpot = pEntry;
Counter++;
}
// rehash entries in Name->Id table
for ( e = 0; e < p->nBins; e++ )
for ( pEntry = p->pBinsN2I[e], pEntry2 = pEntry? pEntry->pNextN2I : NULL;
pEntry; pEntry = pEntry2, pEntry2 = pEntry? pEntry->pNextN2I : NULL )
{
ppSpot = pBinsNewN2I + Nm_HashString(pEntry->Name, nBinsNew);
pEntry->pNextN2I = *ppSpot;
*ppSpot = pEntry;
}
assert( Counter == p->nEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", p->nBins, nBinsNew );
// PRT( "Time", clock() - clk );
......
......@@ -304,9 +304,9 @@ void ABC_Network_Finalize( ABC_Manager mng )
Abc_Obj_t * pObj;
int 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_NtkLogicStoreName( pObj, ABC_GetNodeName(mng, pObj) );
Abc_ObjAssignName( pObj, ABC_GetNodeName(mng, pObj), NULL );
assert( Abc_NtkLatchNum(pNtk) == 0 );
}
......
......@@ -752,7 +752,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
if ( Abc_NtkIsNetlist(pNtkGate) )
pNetFormal = Abc_NtkFindNet( pNtkGate, pWord );
else // if ( Abc_NtkIsStrash(pNtkGate) )
pNetFormal = Abc_NtkFindTerm( pNtkGate, pWord );
assert( 0 );
if ( pNetFormal == NULL )
{
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 )
memset( pPolarity, 0, nBytes );
}
// create box to represent this gate
pNode = Abc_NtkCreateBox( pMan->pNtkCur );
pNode = Abc_NtkCreateBlackbox( pMan->pNtkCur );
pNode->pNext = (Abc_Obj_t *)pPolarity;
pNode->pData = pNtkGate;
// 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