35static int Abc_NtkCheckNames(
Abc_Ntk_t * pNtk );
36static int Abc_NtkCheckPis(
Abc_Ntk_t * pNtk );
37static int Abc_NtkCheckPos(
Abc_Ntk_t * pNtk );
47static inline char * Abc_ObjNameNet(
Abc_Obj_t * pObj ) {
return (Abc_ObjIsNode(pObj) && Abc_NtkIsNetlist(pObj->
pNtk)) ?
Abc_ObjName(Abc_ObjFanout0(pObj)) :
Abc_ObjName(pObj); }
102 if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
104 fprintf( stdout,
"NetworkCheck: Unknown network type.\n" );
107 if ( !Abc_NtkHasSop(pNtk) && !Abc_NtkHasBdd(pNtk) && !Abc_NtkHasAig(pNtk) && !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasBlifMv(pNtk) && !Abc_NtkHasBlackbox(pNtk) )
109 fprintf( stdout,
"NetworkCheck: Unknown functionality type.\n" );
112 if ( Abc_NtkHasMapping(pNtk) )
116 fprintf( stdout,
"NetworkCheck: The library of the mapped network is not the global library.\n" );
121 if ( Abc_NtkHasOnlyLatchBoxes(pNtk) )
124 if ( Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCiNum(pNtk) )
126 fprintf( stdout,
"NetworkCheck: Number of CIs does not match number of PIs and latches.\n" );
127 fprintf( stdout,
"One possible reason is that latches are added twice:\n" );
128 fprintf( stdout,
"in procedure Abc_NtkCreateObj() and in the user's code.\n" );
131 if ( Abc_NtkPoNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) )
133 fprintf( stdout,
"NetworkCheck: Number of COs does not match number of POs, asserts, and latches.\n" );
134 fprintf( stdout,
"One possible reason is that latches are added twice:\n" );
135 fprintf( stdout,
"in procedure Abc_NtkCreateObj() and in the user's code.\n" );
141 if ( !Abc_NtkCheckNames( pNtk ) )
146 if ( !Abc_NtkCheckPis( pNtk ) )
148 if ( !Abc_NtkCheckPos( pNtk ) )
151 if ( Abc_NtkHasBlackbox(pNtk) )
160 if ( Abc_NtkIsNetlist(pNtk) )
162 if ( Abc_NtkNetNum(pNtk) == 0 )
163 fprintf( stdout,
"NetworkCheck: Warning! Netlist has no nets.\n" );
166 if ( !Abc_NtkCheckNet( pNtk, pNet ) )
171 if ( Abc_NtkNetNum(pNtk) != 0 )
173 fprintf( stdout,
"NetworkCheck: A network that is not a netlist has nets.\n" );
179 if ( Abc_NtkIsStrash(pNtk) )
187 if ( !Abc_NtkCheckNode( pNtk, pNode ) )
193 if ( !Abc_NtkCheckLatch( pNtk, pNode ) )
200 fprintf( stdout,
"NetworkCheck: Network contains a combinational loop.\n" );
251 if ( Abc_NtkIsNetlist(pNtk) )
257 pObj = Abc_ObjFanout0Ntk(pObj);
260 fprintf( stdout,
"NetworkCheck: CI with ID %d is in the network but not in the name table.\n", pObj->
Id );
266 pObj = Abc_ObjFanin0Ntk(pObj);
269 fprintf( stdout,
"NetworkCheck: CO with ID %d is in the network but not in the name table.\n", pObj->
Id );
281 if ( Vec_PtrEntry( pNtk->
vObjs, NameId ) == NULL )
283 Vec_IntFree( vNameIds );
285 fprintf( stdout,
"NetworkCheck: Object with ID %d is deleted but its name \"%s\" remains in the name table.\n", NameId, pName );
289 Vec_IntFree( vNameIds );
326 if ( !Abc_ObjIsPi(pObj) )
328 fprintf( stdout,
"NetworkCheck: Object \"%s\" (id=%d) is in the PI list but is not a PI.\n",
Abc_ObjName(pObj), pObj->
Id );
333 fprintf( stdout,
"NetworkCheck: A PI \"%s\" has a logic function.\n",
Abc_ObjName(pObj) );
336 if ( Abc_ObjFaninNum(pObj) > 0 )
338 fprintf( stdout,
"NetworkCheck: A PI \"%s\" has fanins.\n",
Abc_ObjName(pObj) );
345 if ( pObj->
pCopy == NULL && Abc_ObjIsPi(pObj) )
347 fprintf( stdout,
"NetworkCheck: Object \"%s\" (id=%d) is a PI but is not in the PI list.\n",
Abc_ObjName(pObj), pObj->
Id );
374 if ( !Abc_ObjIsPo(pObj) )
376 fprintf( stdout,
"NetworkCheck: Net \"%s\" (id=%d) is in the PO list but is not a PO.\n",
Abc_ObjName(pObj), pObj->
Id );
381 fprintf( stdout,
"NetworkCheck: A PO \"%s\" has a logic function.\n",
Abc_ObjName(pObj) );
384 if ( Abc_ObjFaninNum(pObj) != 1 )
386 fprintf( stdout,
"NetworkCheck: A PO \"%s\" does not have one fanin (but %d).\n",
Abc_ObjName(pObj), Abc_ObjFaninNum(pObj) );
389 if ( Abc_ObjFanoutNum(pObj) > 0 )
391 fprintf( stdout,
"NetworkCheck: A PO \"%s\" has %d fanout(s).\n",
Abc_ObjName(pObj), Abc_ObjFanoutNum(pObj) );
398 if ( pObj->
pCopy == NULL && Abc_ObjIsPo(pObj) )
400 fprintf( stdout,
"NetworkCheck: Net \"%s\" (id=%d) is in a PO but is not in the PO list.\n",
Abc_ObjName(pObj), pObj->
Id );
427 if ( pObj->
pNtk != pNtk )
429 fprintf( stdout,
"NetworkCheck: Object \"%s\" does not belong to the network.\n",
Abc_ObjName(pObj) );
433 if ( pObj->
Id < 0 || (
int)pObj->
Id >= Abc_NtkObjNumMax(pNtk) )
435 fprintf( stdout,
"NetworkCheck: Object \"%s\" has incorrect ID.\n",
Abc_ObjName(pObj) );
445 if ( Vec_IntFind( &pFanin->
vFanouts, pObj->
Id ) == -1 )
447 fprintf( stdout,
"NodeCheck: Object \"%s\" has fanin ",
Abc_ObjName(pObj) );
448 fprintf( stdout,
"\"%s\" but the fanin does not have it as a fanout.\n",
Abc_ObjName(pFanin) );
455 if ( Vec_IntFind( &pFanout->
vFanins, pObj->
Id ) == -1 )
457 fprintf( stdout,
"NodeCheck: Object \"%s\" has fanout ",
Abc_ObjName(pObj) );
458 fprintf( stdout,
"\"%s\" but the fanout does not have it as a fanin.\n",
Abc_ObjName(pFanout) );
464 for ( i = 0; i < pObj->
vFanins.nSize; i++ )
465 for ( k = i + 1; k < pObj->
vFanins.nSize; k++ )
468 printf(
"Warning: Node %s has",
Abc_ObjName(pObj) );
469 printf(
" duplicated fanin %s.\n",
Abc_ObjName(Abc_ObjFanin(pObj,k)) );
477 for ( i = 0; i < pObj->
vFanouts.nSize; i++ )
478 for ( k = i + 1; k < pObj->
vFanouts.nSize; k++ )
481 printf(
"Warning: Node %s has",
Abc_ObjName(pObj) );
482 printf(
" duplicated fanout %s.\n",
Abc_ObjName(Abc_ObjFanout(pObj,k)) );
501 if ( Abc_ObjFaninNum(pNet) == 0 )
503 fprintf( stdout,
"NetworkCheck: Net \"%s\" is not driven.\n",
Abc_ObjName(pNet) );
506 if ( Abc_ObjFaninNum(pNet) > 1 )
508 fprintf( stdout,
"NetworkCheck: Net \"%s\" has more than one driver.\n",
Abc_ObjName(pNet) );
528 if ( Abc_NtkIsNetlist(pNtk) && Abc_ObjFanoutNum(pNode) == 0 )
530 fprintf( stdout,
"Node (id = %d) has no net to drive.\n", pNode->
Id );
534 if ( pNode->
pData == NULL )
536 if ( Abc_ObjIsBarBuf(pNode) )
538 fprintf( stdout,
"NodeCheck: An internal node \"%s\" does not have a logic function.\n", Abc_ObjNameNet(pNode) );
542 if ( Abc_NtkHasSop(pNtk) )
546 fprintf( stdout,
"NodeCheck: SOP check for node \"%s\" has failed.\n", Abc_ObjNameNet(pNode) );
550 else if ( Abc_NtkHasBdd(pNtk) )
553 int nSuppSize = Cudd_SupportSize((DdManager *)pNtk->
pManFunc, (DdNode *)pNode->
pData);
554 if ( nSuppSize > Abc_ObjFaninNum(pNode) )
556 fprintf( stdout,
"NodeCheck: BDD of the node \"%s\" has incorrect support size.\n", Abc_ObjNameNet(pNode) );
561 else if ( !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasBlifMv(pNtk) && !Abc_NtkHasAig(pNtk) )
583 if ( !Abc_ObjIsLatch(pLatch) )
585 fprintf( stdout,
"NodeCheck: Latch \"%s\" is in a latch list but is not a latch.\n",
Abc_ObjName(pLatch) );
591 fprintf( stdout,
"NodeCheck: Latch \"%s\" has incorrect reset value (%d).\n",
596 if ( Abc_ObjFaninNum(pLatch) != 1 )
598 fprintf( stdout,
"NodeCheck: Latch \"%s\" has wrong number (%d) of fanins.\n",
Abc_ObjName(pLatch), Abc_ObjFaninNum(pLatch) );
602 if ( Abc_ObjFanoutNum(pLatch) != 1 )
604 fprintf( stdout,
"NodeCheck: Latch \"%s\" has wrong number (%d) of fanouts.\n",
Abc_ObjName(pLatch), Abc_ObjFanoutNum(pLatch) );
608 if ( Abc_ObjFaninNum(Abc_ObjFanin0(pLatch)) != 1 )
610 fprintf( stdout,
"NodeCheck: Input of latch \"%s\" has wrong number (%d) of fanins.\n",
611 Abc_ObjName(Abc_ObjFanin0(pLatch)), Abc_ObjFaninNum(Abc_ObjFanin0(pLatch)) );
615 if ( Abc_ObjFanoutNum(Abc_ObjFanin0(pLatch)) != 1 )
617 fprintf( stdout,
"NodeCheck: Input of latch \"%s\" has wrong number (%d) of fanouts.\n",
618 Abc_ObjName(Abc_ObjFanin0(pLatch)), Abc_ObjFanoutNum(Abc_ObjFanin0(pLatch)) );
622 if ( Abc_ObjFaninNum(Abc_ObjFanout0(pLatch)) != 1 )
624 fprintf( stdout,
"NodeCheck: Output of latch \"%s\" has wrong number (%d) of fanins.\n",
625 Abc_ObjName(Abc_ObjFanout0(pLatch)), Abc_ObjFaninNum(Abc_ObjFanout0(pLatch)) );
649 if ( Abc_NtkPiNum(pNtk1) != Abc_NtkPiNum(pNtk2) )
651 printf(
"Networks have different number of primary inputs.\n" );
659 printf(
"Primary input #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
682 if ( Abc_NtkPoNum(pNtk1) != Abc_NtkPoNum(pNtk2) )
684 printf(
"Networks have different number of primary outputs.\n" );
692 printf(
"Primary output #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
715 assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
716 assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
719 if ( Abc_NtkBoxNum(pNtk1) != Abc_NtkBoxNum(pNtk2) )
721 printf(
"Networks have different number of latches.\n" );
729 printf(
"Box #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
753 if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
759 if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) )
786 if ( Abc_NtkHasBlackbox(pNtk) )
788 assert( Abc_NtkIsNetlist(pNtk) );
792 if ( Abc_ObjIsLatch(pObj) )
795 assert( pNtkNext != NULL );
848 return strcmp( *pName1, *pName2 );
866 int i, fRetValue = 1;
867 assert( !Abc_NtkIsNetlist(pNtk) );
868 vNames = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
872 for ( i = 1; i < Abc_NtkCiNum(pNtk); i++ )
873 if ( !
strcmp( (
const char *)Vec_PtrEntry(vNames,i-1), (
const char *)Vec_PtrEntry(vNames,i) ) )
875 printf(
"Abc_NtkCheck: Repeated CI names: %s and %s.\n", (
char*)Vec_PtrEntry(vNames,i-1), (
char*)Vec_PtrEntry(vNames,i) );
878 Vec_PtrFree( vNames );
897 int i, fRetValue = 1;
898 assert( !Abc_NtkIsNetlist(pNtk) );
899 vNames = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
903 for ( i = 1; i < Abc_NtkCoNum(pNtk); i++ )
906 if ( !
strcmp( (
const char *)Vec_PtrEntry(vNames,i-1), (
const char *)Vec_PtrEntry(vNames,i) ) )
908 printf(
"Abc_NtkCheck: Repeated CO names: %s and %s.\n", (
char*)Vec_PtrEntry(vNames,i-1), (
char*)Vec_PtrEntry(vNames,i) );
912 Vec_PtrFree( vNames );
930 int i, nCiId, fRetValue = 1;
931 assert( !Abc_NtkIsNetlist(pNtk) );
937 pObjCi = Abc_NtkObj( pNtk, nCiId );
939 pFanin = Abc_ObjFanin0(pObj);
940 if ( pFanin != pObjCi )
942 printf(
"Abc_NtkCheck: A CI/CO pair share the name (%s) but do not link directly. The name of the CO fanin is %s.\n",
int Abc_NtkCompareSignals(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOnlyPis, int fComb)
int Abc_NtkCheckUniqueCoNames(Abc_Ntk_t *pNtk)
int Abc_NtkCheckUniqueCioNames(Abc_Ntk_t *pNtk)
int Abc_NtkIsAcyclicHierarchy_rec(Abc_Ntk_t *pNtk)
int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
int Abc_NtkCheckUniqueCiNames(Abc_Ntk_t *pNtk)
int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
int Abc_NtkDoCheck(Abc_Ntk_t *pNtk)
int Abc_NtkIsAcyclicHierarchy(Abc_Ntk_t *pNtk)
int Abc_NtkCheckObj(Abc_Ntk_t *pNtk, Abc_Obj_t *pObj)
int Abc_NtkCompareBoxes(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fComb)
int Abc_NtkNamesCompare(char **pName1, char **pName2)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
#define Abc_NtkForEachNet(pNtk, pNet, i)
ABC_DLL void Abc_NtkOrderObjsByName(Abc_Ntk_t *pNtk, int fComb)
#define Abc_NtkForEachPo(pNtk, pPo, i)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
ABC_DLL int Abc_SopCheck(char *pSop, int nFanins)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
struct Abc_Aig_t_ Abc_Aig_t
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_AigCheck(Abc_Aig_t *pMan)
#define Abc_NtkForEachPi(pNtk, pPi, i)
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachBox(pNtk, pObj, i)
ABC_DLL int Abc_NtkIsAcyclic(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibGen()
ABC_DLL int Abc_FrameIsFlagEnabled(char *pFlag)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Vec_Int_t * Nm_ManReturnNameIds(Nm_Man_t *p)
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)
int Nm_ManFindIdByNameTwoTypes(Nm_Man_t *p, char *pName, int Type1, int Type2)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.