ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcDebug.c File Reference
#include "base/abc/abc.h"
#include "base/io/ioAbc.h"
Include dependency graph for abcDebug.c:

Go to the source code of this file.

Functions

void Abc_NtkAutoDebug (Abc_Ntk_t *pNtk, int(*pFuncError)(Abc_Ntk_t *))
 FUNCTION DEFINITIONS ///.
 
int Abc_NtkFindGivenFanin (Abc_Ntk_t *pNtk, int Step, Abc_Obj_t **ppObj, Abc_Obj_t **ppFanin)
 

Function Documentation

◆ Abc_NtkAutoDebug()

void Abc_NtkAutoDebug ( Abc_Ntk_t * pNtk,
int(* pFuncError )(Abc_Ntk_t *) )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Takes a network and a procedure to test.]

Description [The network demonstrates the bug in the procedure. Procedure should return 1 if the bug is demonstrated.]

SideEffects []

SeeAlso []

Definition at line 50 of file abcDebug.c.

51{
52 Abc_Ntk_t * pNtkMod;
53 char * pFileName = "bug_found.blif";
54 int i, nSteps, nIter, ModNum, RandNum = 1;
55 abctime clk, clkTotal = Abc_Clock();
56 assert( Abc_NtkIsLogic(pNtk) );
57 srand( 0x123123 );
58 // create internal copy of the network
59 pNtk = Abc_NtkDup(pNtk);
60 if ( !(*pFuncError)( pNtk ) )
61 {
62 printf( "The original network does not cause the bug. Quitting.\n" );
63 Abc_NtkDelete( pNtk );
64 return;
65 }
66 // perform incremental modifications
67 for ( nIter = 0; ; nIter++ )
68 {
69 clk = Abc_Clock();
70 // count how many ways of modifying the network exists
71 nSteps = 2 * Abc_NtkCountFaninsTotal(pNtk);
72 // try modifying the network as many times
73 RandNum ^= rand();
74 for ( i = 0; i < nSteps; i++ )
75 {
76 // get the shifted number of bug
77 ModNum = (i + RandNum) % nSteps;
78 // get the modified network
79 pNtkMod = Abc_NtkAutoDebugModify( pNtk, ModNum/2, ModNum%2 );
80 // write the network
81 Io_WriteBlifLogic( pNtk, "bug_temp.blif", 1 );
82 // check if the bug is still there
83 if ( (*pFuncError)( pNtkMod ) ) // bug is still there
84 {
85 Abc_NtkDelete( pNtk );
86 pNtk = pNtkMod;
87 break;
88 }
89 else // no bug
90 Abc_NtkDelete( pNtkMod );
91 }
92 printf( "Iter %6d : Latches = %6d. Nodes = %6d. Steps = %6d. Error step = %3d. ",
93 nIter, Abc_NtkLatchNum(pNtk), Abc_NtkNodeNum(pNtk), nSteps, i );
94 ABC_PRT( "Time", Abc_Clock() - clk );
95 if ( i == nSteps ) // could not modify it while preserving the bug
96 break;
97 }
98 // write out the final network
99 Io_WriteBlifLogic( pNtk, pFileName, 1 );
100 printf( "Final network written into file \"%s\". ", pFileName );
101 ABC_PRT( "Total time", Abc_Clock() - clkTotal );
102 Abc_NtkDelete( pNtk );
103}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
void Io_WriteBlifLogic(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
FUNCTION DEFINITIONS ///.
Definition ioWriteBlif.c:59
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Abc_NtkFindGivenFanin()

int Abc_NtkFindGivenFanin ( Abc_Ntk_t * pNtk,
int Step,
Abc_Obj_t ** ppObj,
Abc_Obj_t ** ppFanin )

Function*************************************************************

Synopsis [Returns the node and fanin to be modified.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file abcDebug.c.

146{
147 Abc_Obj_t * pObj, * pFanin;
148 int i, k, Counter = 0;
149 Abc_NtkForEachObj( pNtk, pObj, i )
150 Abc_ObjForEachFanin( pObj, pFanin, k )
151 {
152 if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsPo(pObj) )
153 continue;
154 if ( Abc_ObjIsPo(pObj) && Abc_NtkPoNum(pNtk) == 1 )
155 continue;
156 if ( Abc_ObjIsNode(pObj) && Abc_NodeIsConst(pFanin) )
157 continue;
158 if ( Counter++ == Step )
159 {
160 *ppObj = pObj;
161 *ppFanin = pFanin;
162 return 1;
163 }
164 }
165 return 0;
166}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#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_NodeIsConst(Abc_Obj_t *pNode)
Definition abcObj.c:867
Here is the call graph for this function: