ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcCheck.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22#include "base/main/main.h"
23
24#ifdef ABC_USE_CUDD
25#include "bdd/extrab/extraBdd.h"
26#endif
27
29
30
34
35static int Abc_NtkCheckNames( Abc_Ntk_t * pNtk );
36static int Abc_NtkCheckPis( Abc_Ntk_t * pNtk );
37static int Abc_NtkCheckPos( Abc_Ntk_t * pNtk );
38//static int Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
39static int Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet );
40static int Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode );
41static int Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch );
42
43static int Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
44static int Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
45static int Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
46
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); }
48
52
65{
66 return !Abc_FrameIsFlagEnabled( "check" ) || Abc_NtkDoCheck( pNtk );
67}
68
81{
82 return !Abc_FrameIsFlagEnabled( "checkread" ) || Abc_NtkDoCheck( pNtk );
83}
84
97{
98 Abc_Obj_t * pObj, * pNet, * pNode;
99 int i;
100
101 // check network types
102 if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
103 {
104 fprintf( stdout, "NetworkCheck: Unknown network type.\n" );
105 return 0;
106 }
107 if ( !Abc_NtkHasSop(pNtk) && !Abc_NtkHasBdd(pNtk) && !Abc_NtkHasAig(pNtk) && !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasBlifMv(pNtk) && !Abc_NtkHasBlackbox(pNtk) )
108 {
109 fprintf( stdout, "NetworkCheck: Unknown functionality type.\n" );
110 return 0;
111 }
112 if ( Abc_NtkHasMapping(pNtk) )
113 {
114 if ( pNtk->pManFunc != Abc_FrameReadLibGen() )
115 {
116 fprintf( stdout, "NetworkCheck: The library of the mapped network is not the global library.\n" );
117 return 0;
118 }
119 }
120
121 if ( Abc_NtkHasOnlyLatchBoxes(pNtk) )
122 {
123 // check CI/CO numbers
124 if ( Abc_NtkPiNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCiNum(pNtk) )
125 {
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" );
129 return 0;
130 }
131 if ( Abc_NtkPoNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) )
132 {
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" );
136 return 0;
137 }
138 }
139
140 // check the names
141 if ( !Abc_NtkCheckNames( pNtk ) )
142 return 0;
143
144 // check PIs and POs
145 Abc_NtkCleanCopy( pNtk );
146 if ( !Abc_NtkCheckPis( pNtk ) )
147 return 0;
148 if ( !Abc_NtkCheckPos( pNtk ) )
149 return 0;
150
151 if ( Abc_NtkHasBlackbox(pNtk) )
152 return 1;
153
154 // check the connectivity of objects
155 Abc_NtkForEachObj( pNtk, pObj, i )
156 if ( !Abc_NtkCheckObj( pNtk, pObj ) )
157 return 0;
158
159 // if it is a netlist change nets and latches
160 if ( Abc_NtkIsNetlist(pNtk) )
161 {
162 if ( Abc_NtkNetNum(pNtk) == 0 )
163 fprintf( stdout, "NetworkCheck: Warning! Netlist has no nets.\n" );
164 // check the nets
165 Abc_NtkForEachNet( pNtk, pNet, i )
166 if ( !Abc_NtkCheckNet( pNtk, pNet ) )
167 return 0;
168 }
169 else
170 {
171 if ( Abc_NtkNetNum(pNtk) != 0 )
172 {
173 fprintf( stdout, "NetworkCheck: A network that is not a netlist has nets.\n" );
174 return 0;
175 }
176 }
177
178 // check the nodes
179 if ( Abc_NtkIsStrash(pNtk) )
180 {
181 if ( !Abc_AigCheck( (Abc_Aig_t *)pNtk->pManFunc ) )
182 return 0;
183 }
184 else
185 {
186 Abc_NtkForEachNode( pNtk, pNode, i )
187 if ( !Abc_NtkCheckNode( pNtk, pNode ) )
188 return 0;
189 }
190
191 // check the latches
192 Abc_NtkForEachLatch( pNtk, pNode, i )
193 if ( !Abc_NtkCheckLatch( pNtk, pNode ) )
194 return 0;
195
196 // finally, check for combinational loops
197// clk = Abc_Clock();
198 if ( !Abc_NtkIsAcyclic( pNtk ) )
199 {
200 fprintf( stdout, "NetworkCheck: Network contains a combinational loop.\n" );
201 return 0;
202 }
203// ABC_PRT( "Acyclic ", Abc_Clock() - clk );
204
205 // check the EXDC network if present
206 if ( pNtk->pExdc )
207 Abc_NtkCheck( pNtk->pExdc );
208/*
209 // check the hierarchy
210 if ( Abc_NtkIsNetlist(pNtk) && pNtk->tName2Model )
211 {
212 stmm_generator * gen;
213 Abc_Ntk_t * pNtkTemp;
214 char * pName;
215 // check other networks
216 stmm_foreach_item( pNtk->tName2Model, gen, &pName, (char **)&pNtkTemp )
217 {
218 pNtkTemp->fHiePath = pNtkTemp->fHieVisited = 0;
219 if ( !Abc_NtkCheck( pNtkTemp ) )
220 return 0;
221 }
222 // check acyclic dependency of the models
223 if ( !Abc_NtkIsAcyclicHierarchy( pNtk ) )
224 {
225 fprintf( stdout, "NetworkCheck: Network hierarchical dependences contains a cycle.\n" );
226 return 0;
227 }
228 }
229*/
230 return 1;
231}
232
244int Abc_NtkCheckNames( Abc_Ntk_t * pNtk )
245{
246 Abc_Obj_t * pObj = NULL; // Ensure pObj isn't used uninitialized.
247 Vec_Int_t * vNameIds;
248 char * pName;
249 int i, NameId;
250
251 if ( Abc_NtkIsNetlist(pNtk) )
252 return 1;
253
254 // check that each CI/CO has a name
255 Abc_NtkForEachCi( pNtk, pObj, i )
256 {
257 pObj = Abc_ObjFanout0Ntk(pObj);
258 if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
259 {
260 fprintf( stdout, "NetworkCheck: CI with ID %d is in the network but not in the name table.\n", pObj->Id );
261 return 0;
262 }
263 }
264 Abc_NtkForEachCo( pNtk, pObj, i )
265 {
266 pObj = Abc_ObjFanin0Ntk(pObj);
267 if ( Nm_ManFindNameById(pObj->pNtk->pManName, pObj->Id) == NULL )
268 {
269 fprintf( stdout, "NetworkCheck: CO with ID %d is in the network but not in the name table.\n", pObj->Id );
270 return 0;
271 }
272 }
273
274 assert(pObj); // pObj should point to something here.
275
276 // return the array of all IDs, which have names
277 vNameIds = Nm_ManReturnNameIds( pNtk->pManName );
278 // make sure that these IDs correspond to live objects
279 Vec_IntForEachEntry( vNameIds, NameId, i )
280 {
281 if ( Vec_PtrEntry( pNtk->vObjs, NameId ) == NULL )
282 {
283 Vec_IntFree( vNameIds );
284 pName = Nm_ManFindNameById(pObj->pNtk->pManName, NameId);
285 fprintf( stdout, "NetworkCheck: Object with ID %d is deleted but its name \"%s\" remains in the name table.\n", NameId, pName );
286 return 0;
287 }
288 }
289 Vec_IntFree( vNameIds );
290
291 // make sure the CI names are unique
292 if ( !Abc_NtkCheckUniqueCiNames(pNtk) )
293 return 0;
294
295 // make sure the CO names are unique
296 if ( !Abc_NtkCheckUniqueCoNames(pNtk) )
297 return 0;
298
299 // make sure that if a CO has the same name as a CI, they point directly
300 if ( !Abc_NtkCheckUniqueCioNames(pNtk) )
301 return 0;
302
303 return 1;
304}
305
306
318int Abc_NtkCheckPis( Abc_Ntk_t * pNtk )
319{
320 Abc_Obj_t * pObj;
321 int i;
322
323 // check that PIs are indeed PIs
324 Abc_NtkForEachPi( pNtk, pObj, i )
325 {
326 if ( !Abc_ObjIsPi(pObj) )
327 {
328 fprintf( stdout, "NetworkCheck: Object \"%s\" (id=%d) is in the PI list but is not a PI.\n", Abc_ObjName(pObj), pObj->Id );
329 return 0;
330 }
331 if ( pObj->pData )
332 {
333 fprintf( stdout, "NetworkCheck: A PI \"%s\" has a logic function.\n", Abc_ObjName(pObj) );
334 return 0;
335 }
336 if ( Abc_ObjFaninNum(pObj) > 0 )
337 {
338 fprintf( stdout, "NetworkCheck: A PI \"%s\" has fanins.\n", Abc_ObjName(pObj) );
339 return 0;
340 }
341 pObj->pCopy = (Abc_Obj_t *)1;
342 }
343 Abc_NtkForEachObj( pNtk, pObj, i )
344 {
345 if ( pObj->pCopy == NULL && Abc_ObjIsPi(pObj) )
346 {
347 fprintf( stdout, "NetworkCheck: Object \"%s\" (id=%d) is a PI but is not in the PI list.\n", Abc_ObjName(pObj), pObj->Id );
348 return 0;
349 }
350 pObj->pCopy = NULL;
351 }
352 return 1;
353}
354
366int Abc_NtkCheckPos( Abc_Ntk_t * pNtk )
367{
368 Abc_Obj_t * pObj;
369 int i;
370
371 // check that POs are indeed POs
372 Abc_NtkForEachPo( pNtk, pObj, i )
373 {
374 if ( !Abc_ObjIsPo(pObj) )
375 {
376 fprintf( stdout, "NetworkCheck: Net \"%s\" (id=%d) is in the PO list but is not a PO.\n", Abc_ObjName(pObj), pObj->Id );
377 return 0;
378 }
379 if ( pObj->pData )
380 {
381 fprintf( stdout, "NetworkCheck: A PO \"%s\" has a logic function.\n", Abc_ObjName(pObj) );
382 return 0;
383 }
384 if ( Abc_ObjFaninNum(pObj) != 1 )
385 {
386 fprintf( stdout, "NetworkCheck: A PO \"%s\" does not have one fanin (but %d).\n", Abc_ObjName(pObj), Abc_ObjFaninNum(pObj) );
387 return 0;
388 }
389 if ( Abc_ObjFanoutNum(pObj) > 0 )
390 {
391 fprintf( stdout, "NetworkCheck: A PO \"%s\" has %d fanout(s).\n", Abc_ObjName(pObj), Abc_ObjFanoutNum(pObj) );
392 return 0;
393 }
394 pObj->pCopy = (Abc_Obj_t *)1;
395 }
396 Abc_NtkForEachObj( pNtk, pObj, i )
397 {
398 if ( pObj->pCopy == NULL && Abc_ObjIsPo(pObj) )
399 {
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 );
401 return 0;
402 }
403 pObj->pCopy = NULL;
404 }
405 return 1;
406}
407
408
421{
422 Abc_Obj_t * pFanin, * pFanout;
423 int Value = 1;
424 int i, k;
425
426 // check the network
427 if ( pObj->pNtk != pNtk )
428 {
429 fprintf( stdout, "NetworkCheck: Object \"%s\" does not belong to the network.\n", Abc_ObjName(pObj) );
430 return 0;
431 }
432 // check the object ID
433 if ( pObj->Id < 0 || (int)pObj->Id >= Abc_NtkObjNumMax(pNtk) )
434 {
435 fprintf( stdout, "NetworkCheck: Object \"%s\" has incorrect ID.\n", Abc_ObjName(pObj) );
436 return 0;
437 }
438
439 if ( !Abc_FrameIsFlagEnabled("checkfio") )
440 return Value;
441
442 // go through the fanins of the object and make sure fanins have this object as a fanout
443 Abc_ObjForEachFanin( pObj, pFanin, i )
444 {
445 if ( Vec_IntFind( &pFanin->vFanouts, pObj->Id ) == -1 )
446 {
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) );
449 Value = 0;
450 }
451 }
452 // go through the fanouts of the object and make sure fanouts have this object as a fanin
453 Abc_ObjForEachFanout( pObj, pFanout, i )
454 {
455 if ( Vec_IntFind( &pFanout->vFanins, pObj->Id ) == -1 )
456 {
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) );
459 Value = 0;
460 }
461 }
462
463 // make sure fanins are not duplicated
464 for ( i = 0; i < pObj->vFanins.nSize; i++ )
465 for ( k = i + 1; k < pObj->vFanins.nSize; k++ )
466 if ( pObj->vFanins.pArray[k] == pObj->vFanins.pArray[i] )
467 {
468 printf( "Warning: Node %s has", Abc_ObjName(pObj) );
469 printf( " duplicated fanin %s.\n", Abc_ObjName(Abc_ObjFanin(pObj,k)) );
470 }
471
472 // save time: do not check large fanout lists
473 if ( pObj->vFanouts.nSize > 100 )
474 return Value;
475
476 // make sure fanouts are not duplicated
477 for ( i = 0; i < pObj->vFanouts.nSize; i++ )
478 for ( k = i + 1; k < pObj->vFanouts.nSize; k++ )
479 if ( pObj->vFanouts.pArray[k] == pObj->vFanouts.pArray[i] )
480 {
481 printf( "Warning: Node %s has", Abc_ObjName(pObj) );
482 printf( " duplicated fanout %s.\n", Abc_ObjName(Abc_ObjFanout(pObj,k)) );
483 }
484
485 return Value;
486}
487
499int Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet )
500{
501 if ( Abc_ObjFaninNum(pNet) == 0 )
502 {
503 fprintf( stdout, "NetworkCheck: Net \"%s\" is not driven.\n", Abc_ObjName(pNet) );
504 return 0;
505 }
506 if ( Abc_ObjFaninNum(pNet) > 1 )
507 {
508 fprintf( stdout, "NetworkCheck: Net \"%s\" has more than one driver.\n", Abc_ObjName(pNet) );
509 return 0;
510 }
511 return 1;
512}
513
525int Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
526{
527 // detect internal nodes that do not have nets
528 if ( Abc_NtkIsNetlist(pNtk) && Abc_ObjFanoutNum(pNode) == 0 )
529 {
530 fprintf( stdout, "Node (id = %d) has no net to drive.\n", pNode->Id );
531 return 0;
532 }
533 // the node should have a function assigned unless it is an AIG
534 if ( pNode->pData == NULL )
535 {
536 if ( Abc_ObjIsBarBuf(pNode) )
537 return 1;
538 fprintf( stdout, "NodeCheck: An internal node \"%s\" does not have a logic function.\n", Abc_ObjNameNet(pNode) );
539 return 0;
540 }
541 // the netlist and SOP logic network should have SOPs
542 if ( Abc_NtkHasSop(pNtk) )
543 {
544 if ( !Abc_SopCheck( (char *)pNode->pData, Abc_ObjFaninNum(pNode) ) )
545 {
546 fprintf( stdout, "NodeCheck: SOP check for node \"%s\" has failed.\n", Abc_ObjNameNet(pNode) );
547 return 0;
548 }
549 }
550 else if ( Abc_NtkHasBdd(pNtk) )
551 {
552#ifdef ABC_USE_CUDD
553 int nSuppSize = Cudd_SupportSize((DdManager *)pNtk->pManFunc, (DdNode *)pNode->pData);
554 if ( nSuppSize > Abc_ObjFaninNum(pNode) )
555 {
556 fprintf( stdout, "NodeCheck: BDD of the node \"%s\" has incorrect support size.\n", Abc_ObjNameNet(pNode) );
557 return 0;
558 }
559#endif
560 }
561 else if ( !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasBlifMv(pNtk) && !Abc_NtkHasAig(pNtk) )
562 {
563 assert( 0 );
564 }
565 return 1;
566}
567
579int Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
580{
581 int Value = 1;
582 // check whether the object is a latch
583 if ( !Abc_ObjIsLatch(pLatch) )
584 {
585 fprintf( stdout, "NodeCheck: Latch \"%s\" is in a latch list but is not a latch.\n", Abc_ObjName(pLatch) );
586 Value = 0;
587 }
588 // make sure the latch has a reasonable return value
589 if ( (int)(ABC_PTRINT_T)pLatch->pData < ABC_INIT_ZERO || (int)(ABC_PTRINT_T)pLatch->pData > ABC_INIT_DC )
590 {
591 fprintf( stdout, "NodeCheck: Latch \"%s\" has incorrect reset value (%d).\n",
592 Abc_ObjName(pLatch), (int)(ABC_PTRINT_T)pLatch->pData );
593 Value = 0;
594 }
595 // make sure the latch has only one fanin
596 if ( Abc_ObjFaninNum(pLatch) != 1 )
597 {
598 fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanins.\n", Abc_ObjName(pLatch), Abc_ObjFaninNum(pLatch) );
599 Value = 0;
600 }
601 // make sure the latch has only one fanout
602 if ( Abc_ObjFanoutNum(pLatch) != 1 )
603 {
604 fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanouts.\n", Abc_ObjName(pLatch), Abc_ObjFanoutNum(pLatch) );
605 Value = 0;
606 }
607 // make sure the latch input has only one fanin
608 if ( Abc_ObjFaninNum(Abc_ObjFanin0(pLatch)) != 1 )
609 {
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)) );
612 Value = 0;
613 }
614 // make sure the latch input has only one fanout
615 if ( Abc_ObjFanoutNum(Abc_ObjFanin0(pLatch)) != 1 )
616 {
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)) );
619 Value = 0;
620 }
621 // make sure the latch output has only one fanin
622 if ( Abc_ObjFaninNum(Abc_ObjFanout0(pLatch)) != 1 )
623 {
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)) );
626 Value = 0;
627 }
628 return Value;
629}
630
631
632
633
645int Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
646{
647 Abc_Obj_t * pObj1;
648 int i;
649 if ( Abc_NtkPiNum(pNtk1) != Abc_NtkPiNum(pNtk2) )
650 {
651 printf( "Networks have different number of primary inputs.\n" );
652 return 0;
653 }
654 // for each PI of pNet1 find corresponding PI of pNet2 and reorder them
655 Abc_NtkForEachPi( pNtk1, pObj1, i )
656 {
657 if ( strcmp( Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkPi(pNtk2,i)) ) != 0 )
658 {
659 printf( "Primary input #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
660 i, Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkPi(pNtk2,i)) );
661 return 0;
662 }
663 }
664 return 1;
665}
666
678int Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
679{
680 Abc_Obj_t * pObj1;
681 int i;
682 if ( Abc_NtkPoNum(pNtk1) != Abc_NtkPoNum(pNtk2) )
683 {
684 printf( "Networks have different number of primary outputs.\n" );
685 return 0;
686 }
687 // for each PO of pNet1 find corresponding PO of pNet2 and reorder them
688 Abc_NtkForEachPo( pNtk1, pObj1, i )
689 {
690 if ( strcmp( Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkPo(pNtk2,i)) ) != 0 )
691 {
692 printf( "Primary output #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
693 i, Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkPo(pNtk2,i)) );
694 return 0;
695 }
696 }
697 return 1;
698}
699
711int Abc_NtkCompareBoxes( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
712{
713 Abc_Obj_t * pObj1;
714 int i;
715 assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
716 assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
717 if ( !fComb )
718 return 1;
719 if ( Abc_NtkBoxNum(pNtk1) != Abc_NtkBoxNum(pNtk2) )
720 {
721 printf( "Networks have different number of latches.\n" );
722 return 0;
723 }
724 // for each PI of pNet1 find corresponding PI of pNet2 and reorder them
725 Abc_NtkForEachBox( pNtk1, pObj1, i )
726 {
727 if ( strcmp( Abc_ObjName(Abc_ObjFanout0(pObj1)), Abc_ObjName(Abc_ObjFanout0(Abc_NtkBox(pNtk2,i))) ) != 0 )
728 {
729 printf( "Box #%d is different in network 1 ( \"%s\") and in network 2 (\"%s\").\n",
730 i, Abc_ObjName(Abc_ObjFanout0(pObj1)), Abc_ObjName(Abc_ObjFanout0(Abc_NtkBox(pNtk2,i))) );
731 return 0;
732 }
733 }
734 return 1;
735}
736
749int Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb )
750{
751 Abc_NtkOrderObjsByName( pNtk1, fComb );
752 Abc_NtkOrderObjsByName( pNtk2, fComb );
753 if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
754 return 0;
755 if ( !fOnlyPis )
756 {
757 if ( !Abc_NtkCompareBoxes( pNtk1, pNtk2, fComb ) )
758 return 0;
759 if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) )
760 return 0;
761 }
762 return 1;
763}
764
777{
778 Abc_Ntk_t * pNtkNext;
779 Abc_Obj_t * pObj;
780 int i;
781 // return if visited
782 if ( pNtk->fHieVisited )
783 return 1;
784 pNtk->fHieVisited = 1;
785 // return if black box
786 if ( Abc_NtkHasBlackbox(pNtk) )
787 return 1;
788 assert( Abc_NtkIsNetlist(pNtk) );
789 // go through all the children networks
790 Abc_NtkForEachBox( pNtk, pObj, i )
791 {
792 if ( Abc_ObjIsLatch(pObj) )
793 continue;
794 pNtkNext = (Abc_Ntk_t *)pObj->pData;
795 assert( pNtkNext != NULL );
796 if ( pNtkNext->fHiePath )
797 return 0;
798 pNtk->fHiePath = 1;
799 if ( !Abc_NtkIsAcyclicHierarchy_rec( pNtkNext ) )
800 return 0;
801 pNtk->fHiePath = 0;
802 }
803 return 1;
804}
805
818{
819 Abc_Ntk_t * pTemp;
820 int i, RetValue;
821 assert( Abc_NtkIsNetlist(pNtk) && pNtk->pDesign );
822 // clear the modules
823 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pTemp, i )
824 pTemp->fHieVisited = pTemp->fHiePath = 0;
825 // traverse
826 pNtk->fHiePath = 1;
827 RetValue = Abc_NtkIsAcyclicHierarchy_rec( pNtk );
828 pNtk->fHiePath = 0;
829 // clear the modules
830 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pTemp, i )
831 pTemp->fHieVisited = pTemp->fHiePath = 0;
832 return RetValue;
833}
834
846int Abc_NtkNamesCompare( char ** pName1, char ** pName2 )
847{
848 return strcmp( *pName1, *pName2 );
849}
850
863{
864 Vec_Ptr_t * vNames;
865 Abc_Obj_t * pObj;
866 int i, fRetValue = 1;
867 assert( !Abc_NtkIsNetlist(pNtk) );
868 vNames = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
869 Abc_NtkForEachCi( pNtk, pObj, i )
870 Vec_PtrPush( vNames, Abc_ObjName(pObj) );
871 Vec_PtrSort( vNames, (int (*)(const void *, const void *))Abc_NtkNamesCompare );
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) ) )
874 {
875 printf( "Abc_NtkCheck: Repeated CI names: %s and %s.\n", (char*)Vec_PtrEntry(vNames,i-1), (char*)Vec_PtrEntry(vNames,i) );
876 fRetValue = 0;
877 }
878 Vec_PtrFree( vNames );
879 return fRetValue;
880}
881
894{
895 Vec_Ptr_t * vNames;
896 Abc_Obj_t * pObj;
897 int i, fRetValue = 1;
898 assert( !Abc_NtkIsNetlist(pNtk) );
899 vNames = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
900 Abc_NtkForEachCo( pNtk, pObj, i )
901 Vec_PtrPush( vNames, Abc_ObjName(pObj) );
902 Vec_PtrSort( vNames, (int (*)(const void *, const void *))Abc_NtkNamesCompare );
903 for ( i = 1; i < Abc_NtkCoNum(pNtk); i++ )
904 {
905// printf( "%s\n", Vec_PtrEntry(vNames,i) );
906 if ( !strcmp( (const char *)Vec_PtrEntry(vNames,i-1), (const char *)Vec_PtrEntry(vNames,i) ) )
907 {
908 printf( "Abc_NtkCheck: Repeated CO names: %s and %s.\n", (char*)Vec_PtrEntry(vNames,i-1), (char*)Vec_PtrEntry(vNames,i) );
909 fRetValue = 0;
910 }
911 }
912 Vec_PtrFree( vNames );
913 return fRetValue;
914}
915
928{
929 Abc_Obj_t * pObj, * pObjCi, * pFanin;
930 int i, nCiId, fRetValue = 1;
931 assert( !Abc_NtkIsNetlist(pNtk) );
932 Abc_NtkForEachCo( pNtk, pObj, i )
933 {
935 if ( nCiId == -1 )
936 continue;
937 pObjCi = Abc_NtkObj( pNtk, nCiId );
938 assert( !strcmp( Abc_ObjName(pObj), Abc_ObjName(pObjCi) ) );
939 pFanin = Abc_ObjFanin0(pObj);
940 if ( pFanin != pObjCi )
941 {
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",
943 Abc_ObjName(pObj), Abc_ObjName(Abc_ObjFanin0(pObj)) );
944 fRetValue = 0;
945 }
946 }
947 return fRetValue;
948}
949
953
954
956
int Abc_NtkCompareSignals(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOnlyPis, int fComb)
Definition abcCheck.c:749
int Abc_NtkCheckUniqueCoNames(Abc_Ntk_t *pNtk)
Definition abcCheck.c:893
int Abc_NtkCheckUniqueCioNames(Abc_Ntk_t *pNtk)
Definition abcCheck.c:927
int Abc_NtkIsAcyclicHierarchy_rec(Abc_Ntk_t *pNtk)
Definition abcCheck.c:776
int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
int Abc_NtkCheckUniqueCiNames(Abc_Ntk_t *pNtk)
Definition abcCheck.c:862
int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition abcCheck.c:80
int Abc_NtkDoCheck(Abc_Ntk_t *pNtk)
Definition abcCheck.c:96
int Abc_NtkIsAcyclicHierarchy(Abc_Ntk_t *pNtk)
Definition abcCheck.c:817
int Abc_NtkCheckObj(Abc_Ntk_t *pNtk, Abc_Obj_t *pObj)
Definition abcCheck.c:420
int Abc_NtkCompareBoxes(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fComb)
Definition abcCheck.c:711
int Abc_NtkNamesCompare(char **pName1, char **pName2)
Definition abcCheck.c:846
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_NtkForEachNet(pNtk, pNet, i)
Definition abc.h:461
ABC_DLL void Abc_NtkOrderObjsByName(Abc_Ntk_t *pNtk, int fComb)
Definition abcNames.c:330
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL int Abc_SopCheck(char *pSop, int nFanins)
Definition abcSop.c:871
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
@ ABC_OBJ_BO
Definition abc.h:92
@ ABC_OBJ_PI
Definition abc.h:89
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
@ ABC_INIT_ZERO
Definition abc.h:104
@ ABC_INIT_DC
Definition abc.h:106
ABC_DLL int Abc_AigCheck(Abc_Aig_t *pMan)
Definition abcAig.c:226
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition abc.h:498
ABC_DLL int Abc_NtkIsAcyclic(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1614
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
ABC_DLL int Abc_FrameIsFlagEnabled(char *pFlag)
Definition mainFrame.c:138
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Vec_Int_t * Nm_ManReturnNameIds(Nm_Man_t *p)
Definition nmApi.c:261
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)
Definition nmApi.c:199
int Nm_ManFindIdByNameTwoTypes(Nm_Man_t *p, char *pName, int Type1, int Type2)
Definition nmApi.c:239
Vec_Ptr_t * vModules
Definition abc.h:225
Abc_Des_t * pDesign
Definition abc.h:180
Abc_Ntk_t * pExdc
Definition abc.h:201
int fHieVisited
Definition abc.h:182
void * pManFunc
Definition abc.h:191
Nm_Man_t * pManName
Definition abc.h:160
Vec_Ptr_t * vObjs
Definition abc.h:162
int fHiePath
Definition abc.h:183
void * pData
Definition abc.h:145
Vec_Int_t vFanins
Definition abc.h:143
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
Vec_Int_t vFanouts
Definition abc.h:144
Abc_Obj_t * pCopy
Definition abc.h:148
#define assert(ex)
Definition util_old.h:213
int strcmp()
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55