src/base/abci/abcDebug.c File Reference

#include "abc.h"
Include dependency graph for abcDebug.c:

Go to the source code of this file.

Functions

static int Abc_NtkCountFaninsTotal (Abc_Ntk_t *pNtk)
static Abc_Ntk_tAbc_NtkAutoDebugModify (Abc_Ntk_t *pNtk, int ObjNum, int fConst1)
void Io_WriteBlifLogic (Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches)
void Abc_NtkAutoDebug (Abc_Ntk_t *pNtk, int(*pFuncError)(Abc_Ntk_t *))
int Abc_NtkFindGivenFanin (Abc_Ntk_t *pNtk, int Step, Abc_Obj_t **ppObj, Abc_Obj_t **ppFanin)

Function Documentation

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

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 48 of file abcDebug.c.

00049 {
00050     Abc_Ntk_t * pNtkMod;
00051     char * pFileName = "bug_found.blif";
00052     int i, nSteps, nIter, ModNum, RandNum = 1, clk, clkTotal = clock();
00053     assert( Abc_NtkIsLogic(pNtk) );
00054     srand( 0x123123 );
00055     // create internal copy of the network
00056     pNtk = Abc_NtkDup(pNtk);
00057     if ( !(*pFuncError)( pNtk ) )
00058     {
00059         printf( "The original network does not cause the bug. Quitting.\n" );
00060         Abc_NtkDelete( pNtk );
00061         return;
00062     }
00063     // perform incremental modifications
00064     for ( nIter = 0; ; nIter++ )
00065     {
00066         clk = clock();
00067         // count how many ways of modifying the network exists
00068         nSteps = 2 * Abc_NtkCountFaninsTotal(pNtk);
00069         // try modifying the network as many times
00070         RandNum ^= rand();
00071         for ( i = 0; i < nSteps; i++ )
00072         {
00073             // get the shifted number of bug
00074             ModNum = (i + RandNum) % nSteps;
00075             // get the modified network
00076             pNtkMod = Abc_NtkAutoDebugModify( pNtk, ModNum/2, ModNum%2 );
00077             // write the network
00078             Io_WriteBlifLogic( pNtk, "bug_temp.blif", 1 );   
00079             // check if the bug is still there
00080             if ( (*pFuncError)( pNtkMod ) ) // bug is still there
00081             {
00082                 Abc_NtkDelete( pNtk );
00083                 pNtk = pNtkMod;
00084                 break;
00085             }
00086             else // no bug
00087                 Abc_NtkDelete( pNtkMod );
00088         }
00089         printf( "Iter %6d : Latches = %6d. Nodes = %6d. Steps = %6d. Error step = %3d.  ", 
00090             nIter, Abc_NtkLatchNum(pNtk), Abc_NtkNodeNum(pNtk), nSteps, i );
00091         PRT( "Time", clock() - clk );
00092         if ( i == nSteps ) // could not modify it while preserving the bug
00093             break;
00094     }
00095     // write out the final network
00096     Io_WriteBlifLogic( pNtk, pFileName, 1 );
00097     printf( "Final network written into file \"%s\". ", pFileName );
00098     PRT( "Total time", clock() - clkTotal );
00099     Abc_NtkDelete( pNtk );
00100 }

Abc_Ntk_t * Abc_NtkAutoDebugModify ( Abc_Ntk_t pNtkInit,
int  Step,
int  fConst1 
) [static]

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

Synopsis [Perform modification with the given number.]

Description [Modification consists of replacing the node by a constant.]

SideEffects []

SeeAlso []

Definition at line 176 of file abcDebug.c.

00177 {
00178     extern void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
00179     Abc_Ntk_t * pNtk;
00180     Abc_Obj_t * pObj, * pFanin, * pConst;
00181     // copy the network
00182     pNtk = Abc_NtkDup( pNtkInit );
00183     assert( Abc_NtkNodeNum(pNtk) == Abc_NtkNodeNum(pNtkInit) );
00184     // find the object number
00185     Abc_NtkFindGivenFanin( pNtk, Step, &pObj, &pFanin );
00186     // consider special case 
00187     if ( Abc_ObjIsPo(pObj) && Abc_NodeIsConst(pFanin) )
00188     {
00189         Abc_NtkDeleteAll_rec( pObj );
00190         return pNtk;
00191     }
00192     // plug in a constant node
00193     pConst = fConst1? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
00194     Abc_ObjTransferFanout( pFanin, pConst );
00195     Abc_NtkDeleteAll_rec( pFanin );
00196 
00197     Abc_NtkSweep( pNtk, 0 );
00198     Abc_NtkCleanupSeq( pNtk, 0, 0, 0 );
00199     Abc_NtkToSop( pNtk, 0 );
00200     Abc_NtkCycleInitStateSop( pNtk, 50, 0 );
00201     return pNtk;
00202 }

int Abc_NtkCountFaninsTotal ( Abc_Ntk_t pNtk  )  [static]

CFile****************************************************************

FileName [abcDebug.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Automated debugging procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
abcDebug.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS ///

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

Synopsis [Counts the total number of fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file abcDebug.c.

00114 {
00115     Abc_Obj_t * pObj, * pFanin;
00116     int i, k, Counter = 0;
00117     Abc_NtkForEachObj( pNtk, pObj, i )
00118         Abc_ObjForEachFanin( pObj, pFanin, k )
00119         {
00120             if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsPo(pObj) )
00121                 continue;
00122             if ( Abc_ObjIsPo(pObj) && Abc_NtkPoNum(pNtk) == 1 )
00123                 continue;
00124             if ( Abc_ObjIsNode(pObj) && Abc_NodeIsConst(pFanin) )
00125                 continue;
00126             Counter++;
00127         }
00128     return Counter;
00129 }

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 142 of file abcDebug.c.

00143 {
00144     Abc_Obj_t * pObj, * pFanin;
00145     int i, k, Counter = 0;
00146     Abc_NtkForEachObj( pNtk, pObj, i )
00147         Abc_ObjForEachFanin( pObj, pFanin, k )
00148         {
00149             if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsPo(pObj) )
00150                 continue;
00151             if ( Abc_ObjIsPo(pObj) && Abc_NtkPoNum(pNtk) == 1 )
00152                 continue;
00153             if ( Abc_ObjIsNode(pObj) && Abc_NodeIsConst(pFanin) )
00154                 continue;
00155             if ( Counter++ == Step )
00156             {
00157                 *ppObj   = pObj;
00158                 *ppFanin = pFanin;
00159                 return 1;
00160             }
00161         }
00162     return 0;
00163 }

void Io_WriteBlifLogic ( Abc_Ntk_t pNtk,
char *  FileName,
int  fWriteLatches 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Write the network into a BLIF file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file ioWriteBlif.c.

00056 {
00057     Abc_Ntk_t * pNtkTemp;
00058     // derive the netlist
00059     pNtkTemp = Abc_NtkToNetlist(pNtk);
00060     if ( pNtkTemp == NULL )
00061     {
00062         fprintf( stdout, "Writing BLIF has failed.\n" );
00063         return;
00064     }
00065     Io_WriteBlif( pNtkTemp, FileName, fWriteLatches );
00066     Abc_NtkDelete( pNtkTemp );
00067 }


Generated on Tue Jan 5 12:18:35 2010 for abc70930 by  doxygen 1.6.1