abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcProve.c File Reference
#include <math.h>
#include "base/abc/abc.h"
#include "proof/fraig/fraig.h"
#include "misc/extra/extraBdd.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Abc_NtkRefactor (Abc_Ntk_t *pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
 DECLARATIONS ///. More...
 
Abc_Ntk_tAbc_NtkFromFraig (Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
 DECLARATIONS ///. More...
 
static Abc_Ntk_tAbc_NtkMiterFraig (Abc_Ntk_t *pNtk, int nBTLimit, ABC_INT64_T nInspLimit, int *pRetValue, int *pNumFails, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
 
static void Abc_NtkMiterPrint (Abc_Ntk_t *pNtk, char *pString, abctime clk, int fVerbose)
 
int Abc_NtkMiterProve (Abc_Ntk_t **ppNtk, void *pPars)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tAbc_NtkMiterRwsat (Abc_Ntk_t *pNtk)
 

Function Documentation

Abc_Ntk_t* Abc_NtkFromFraig ( Fraig_Man_t pMan,
Abc_Ntk_t pNtk 
)

DECLARATIONS ///.

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

FileName [abcFraig.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures interfacing with the FRAIG package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Transforms FRAIG into strashed network with choices.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file abcFraig.c.

280 {
281  ProgressBar * pProgress;
282  Abc_Ntk_t * pNtkNew;
283  Abc_Obj_t * pNode, * pNodeNew;
284  int i;
285  // create the new network
286  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
287  // make the mapper point to the new network
288  Abc_NtkForEachCi( pNtk, pNode, i )
289  Fraig_NodeSetData1( Fraig_ManReadIthVar(pMan, i), (Fraig_Node_t *)pNode->pCopy );
290  // set the constant node
292  // process the nodes in topological order
293  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
294  Abc_NtkForEachCo( pNtk, pNode, i )
295  {
296  Extra_ProgressBarUpdate( pProgress, i, NULL );
297  pNodeNew = Abc_NodeFromFraig_rec( pNtkNew, Fraig_ManReadOutputs(pMan)[i] );
298  Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
299  }
300  Extra_ProgressBarStop( pProgress );
301  Abc_NtkReassignIds( pNtkNew );
302  return pNtkNew;
303 }
Fraig_Node_t * Fraig_ManReadConst1(Fraig_Man_t *p)
Definition: fraigApi.c:52
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
Fraig_Node_t ** Fraig_ManReadOutputs(Fraig_Man_t *p)
Definition: fraigApi.c:47
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1769
DECLARATIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Fraig_Node_t * Fraig_ManReadIthVar(Fraig_Man_t *p, int i)
Definition: fraigApi.c:168
void Fraig_NodeSetData1(Fraig_Node_t *p, Fraig_Node_t *pData)
Definition: fraigApi.c:138
void Extra_ProgressBarStop(ProgressBar *p)
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
static Abc_Obj_t * Abc_NodeFromFraig_rec(Abc_Ntk_t *pNtkNew, Fraig_Node_t *pNodeFraig)
Definition: abcFraig.c:316
Abc_Ntk_t * Abc_NtkMiterFraig ( Abc_Ntk_t pNtk,
int  nBTLimit,
ABC_INT64_T  nInspLimit,
int *  pRetValue,
int *  pNumFails,
ABC_INT64_T *  pNumConfs,
ABC_INT64_T *  pNumInspects 
)
static

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

Synopsis [Attempts to solve the miter using a number of tricks.]

Description [Returns -1 if timed out; 0 if SAT; 1 if UNSAT.]

SideEffects []

SeeAlso []

Definition at line 245 of file abcProve.c.

246 {
247  Abc_Ntk_t * pNtkNew;
248  Fraig_Params_t Params, * pParams = &Params;
249  Fraig_Man_t * pMan;
250  int nWords1, nWords2, nWordsMin, RetValue;
251  int * pModel;
252 
253  // to determine the number of simulation patterns
254  // use the following strategy
255  // at least 64 words (32 words random and 32 words dynamic)
256  // no more than 256M for one circuit (128M + 128M)
257  nWords1 = 32;
258  nWords2 = (1<<27) / (Abc_NtkNodeNum(pNtk) + Abc_NtkCiNum(pNtk));
259  nWordsMin = Abc_MinInt( nWords1, nWords2 );
260 
261  // set the FRAIGing parameters
262  Fraig_ParamsSetDefault( pParams );
263  pParams->nPatsRand = nWordsMin * 32; // the number of words of random simulation info
264  pParams->nPatsDyna = nWordsMin * 32; // the number of words of dynamic simulation info
265  pParams->nBTLimit = nBTLimit; // the max number of backtracks
266  pParams->nSeconds = -1; // the runtime limit
267  pParams->fTryProve = 0; // do not try to prove the final miter
268  pParams->fDoSparse = 1; // try proving sparse functions
269  pParams->fVerbose = 0;
270  pParams->nInspLimit = nInspLimit;
271 
272  // transform the target into a fraig
273  pMan = (Fraig_Man_t *)Abc_NtkToFraig( pNtk, pParams, 0, 0 );
274  Fraig_ManProveMiter( pMan );
275  RetValue = Fraig_ManCheckMiter( pMan );
276 
277  // create the network
278  pNtkNew = Abc_NtkFromFraig( pMan, pNtk );
279 
280  // save model
281  if ( RetValue == 0 )
282  {
283  pModel = Fraig_ManReadModel( pMan );
284  ABC_FREE( pNtkNew->pModel );
285  pNtkNew->pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtkNew) );
286  memcpy( pNtkNew->pModel, pModel, sizeof(int) * Abc_NtkCiNum(pNtkNew) );
287  }
288 
289  // save the return values
290  *pRetValue = RetValue;
291  *pNumFails = Fraig_ManReadSatFails( pMan );
292  *pNumConfs = Fraig_ManReadConflicts( pMan );
293  *pNumInspects = Fraig_ManReadInspects( pMan );
294 
295  // delete the fraig manager
296  Fraig_ManFree( pMan );
297  return pNtkNew;
298 }
typedefABC_NAMESPACE_HEADER_START struct Fraig_ManStruct_t_ Fraig_Man_t
INCLUDES ///.
Definition: fraig.h:40
void Fraig_ManFree(Fraig_Man_t *pMan)
Definition: fraigMan.c:262
ABC_INT64_T nInspLimit
Definition: fraig.h:64
char * memcpy()
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int Fraig_ManReadInspects(Fraig_Man_t *p)
Definition: fraigApi.c:75
int * pModel
Definition: abc.h:198
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
void Fraig_ParamsSetDefault(Fraig_Params_t *pParams)
Definition: fraigMan.c:122
Abc_Ntk_t * Abc_NtkFromFraig(Fraig_Man_t *pMan, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: abcFraig.c:279
int Fraig_ManReadSatFails(Fraig_Man_t *p)
Definition: fraigApi.c:71
#define ABC_FREE(obj)
Definition: abc_global.h:232
int * Fraig_ManReadModel(Fraig_Man_t *p)
Definition: fraigApi.c:63
int Fraig_ManCheckMiter(Fraig_Man_t *p)
Definition: fraigSat.c:130
int Fraig_ManReadConflicts(Fraig_Man_t *p)
Definition: fraigApi.c:73
ABC_DLL void * Abc_NtkToFraig(Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
Definition: abcFraig.c:103
void Fraig_ManProveMiter(Fraig_Man_t *p)
Definition: fraigSat.c:85
void Abc_NtkMiterPrint ( Abc_Ntk_t pNtk,
char *  pString,
abctime  clk,
int  fVerbose 
)
static

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

Synopsis [Attempts to solve the miter using a number of tricks.]

Description [Returns -1 if timed out; 0 if SAT; 1 if UNSAT.]

SideEffects []

SeeAlso []

Definition at line 311 of file abcProve.c.

312 {
313  if ( !fVerbose )
314  return;
315  printf( "Nodes = %7d. Levels = %4d. ", Abc_NtkNodeNum(pNtk),
316  Abc_NtkIsStrash(pNtk)? Abc_AigLevel(pNtk) : Abc_NtkLevel(pNtk) );
317  ABC_PRT( pString, Abc_Clock() - clk );
318 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
Definition: abcAig.c:292
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
int Abc_NtkMiterProve ( Abc_Ntk_t **  ppNtk,
void *  pPars 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Attempts to solve the miter using a number of tricks.]

Description [Returns -1 if timed out; 0 if SAT; 1 if UNSAT. Returns a simplified version of the original network (or a constant 0 network). In case the network is not a constant zero and a SAT assignment is found, pNtk->pModel contains a satisfying assignment.]

SideEffects []

SeeAlso []

Definition at line 59 of file abcProve.c.

60 {
61  Prove_Params_t * pParams = (Prove_Params_t *)pPars;
62  Abc_Ntk_t * pNtk, * pNtkTemp;
63  int RetValue = -1, nIter, nSatFails, Counter;
64  abctime clk; //, timeStart = Abc_Clock();
65  ABC_INT64_T nSatConfs, nSatInspects, nInspectLimit;
66 
67  // get the starting network
68  pNtk = *ppNtk;
69  assert( Abc_NtkIsStrash(pNtk) );
70  assert( Abc_NtkPoNum(pNtk) == 1 );
71 
72  if ( pParams->fVerbose )
73  {
74  printf( "RESOURCE LIMITS: Iterations = %d. Rewriting = %s. Fraiging = %s.\n",
75  pParams->nItersMax, pParams->fUseRewriting? "yes":"no", pParams->fUseFraiging? "yes":"no" );
76  printf( "Miter = %d (%3.1f). Rwr = %d (%3.1f). Fraig = %d (%3.1f). Last = %d.\n",
77  pParams->nMiteringLimitStart, pParams->nMiteringLimitMulti,
78  pParams->nRewritingLimitStart, pParams->nRewritingLimitMulti,
79  pParams->nFraigingLimitStart, pParams->nFraigingLimitMulti, pParams->nMiteringLimitLast );
80  }
81 
82  // if SAT only, solve without iteration
83  if ( !pParams->fUseRewriting && !pParams->fUseFraiging )
84  {
85  clk = Abc_Clock();
86  RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)pParams->nMiteringLimitLast, (ABC_INT64_T)0, 0, NULL, NULL );
87  Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose );
88  *ppNtk = pNtk;
89  return RetValue;
90  }
91 
92  // check the current resource limits
93  for ( nIter = 0; nIter < pParams->nItersMax; nIter++ )
94  {
95  if ( pParams->fVerbose )
96  {
97  printf( "ITERATION %2d : Confs = %6d. FraigBTL = %3d. \n", nIter+1,
98  (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)),
99  (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter)) );
100  fflush( stdout );
101  }
102 
103  // try brute-force SAT
104  clk = Abc_Clock();
105  nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
106  RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)), (ABC_INT64_T)nInspectLimit, 0, &nSatConfs, &nSatInspects );
107  Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose );
108  if ( RetValue >= 0 )
109  break;
110 
111  // add to the number of backtracks and inspects
112  pParams->nTotalBacktracksMade += nSatConfs;
113  pParams->nTotalInspectsMade += nSatInspects;
114  // check if global resource limit is reached
115  if ( (pParams->nTotalBacktrackLimit && pParams->nTotalBacktracksMade >= pParams->nTotalBacktrackLimit) ||
116  (pParams->nTotalInspectLimit && pParams->nTotalInspectsMade >= pParams->nTotalInspectLimit) )
117  {
118  printf( "Reached global limit on conflicts/inspects. Quitting.\n" );
119  *ppNtk = pNtk;
120  return -1;
121  }
122 
123  // try rewriting
124  if ( pParams->fUseRewriting )
125  {
126  clk = Abc_Clock();
127  Counter = (int)(pParams->nRewritingLimitStart * pow(pParams->nRewritingLimitMulti,nIter));
128 // Counter = 1;
129  while ( 1 )
130  {
131 /*
132  extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
133  pNtk = Abc_NtkIvyResyn( pNtkTemp = pNtk, 0, 0 ); Abc_NtkDelete( pNtkTemp );
134  if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
135  break;
136  if ( --Counter == 0 )
137  break;
138 */
139 /*
140  Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
141  if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
142  break;
143  if ( --Counter == 0 )
144  break;
145 */
146  Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
147  if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
148  break;
149  if ( --Counter == 0 )
150  break;
151  Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
152  if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
153  break;
154  if ( --Counter == 0 )
155  break;
156  pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 ); Abc_NtkDelete( pNtkTemp );
157  if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
158  break;
159  if ( --Counter == 0 )
160  break;
161  }
162  Abc_NtkMiterPrint( pNtk, "Rewriting ", clk, pParams->fVerbose );
163  }
164 
165  if ( pParams->fUseFraiging )
166  {
167  // try FRAIGing
168  clk = Abc_Clock();
169  nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
170  pNtk = Abc_NtkMiterFraig( pNtkTemp = pNtk, (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter)), nInspectLimit, &RetValue, &nSatFails, &nSatConfs, &nSatInspects ); Abc_NtkDelete( pNtkTemp );
171  Abc_NtkMiterPrint( pNtk, "FRAIGing ", clk, pParams->fVerbose );
172 // printf( "NumFails = %d\n", nSatFails );
173  if ( RetValue >= 0 )
174  break;
175 
176  // add to the number of backtracks and inspects
177  pParams->nTotalBacktracksMade += nSatConfs;
178  pParams->nTotalInspectsMade += nSatInspects;
179  // check if global resource limit is reached
180  if ( (pParams->nTotalBacktrackLimit && pParams->nTotalBacktracksMade >= pParams->nTotalBacktrackLimit) ||
181  (pParams->nTotalInspectLimit && pParams->nTotalInspectsMade >= pParams->nTotalInspectLimit) )
182  {
183  printf( "Reached global limit on conflicts/inspects. Quitting.\n" );
184  *ppNtk = pNtk;
185  return -1;
186  }
187  }
188 
189  }
190 
191  // try to prove it using brute force SAT
192  if ( RetValue < 0 && pParams->fUseBdds )
193  {
194  if ( pParams->fVerbose )
195  {
196  printf( "Attempting BDDs with node limit %d ...\n", pParams->nBddSizeLimit );
197  fflush( stdout );
198  }
199  clk = Abc_Clock();
200  pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0 );
201  if ( pNtk )
202  {
203  Abc_NtkDelete( pNtkTemp );
204  RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero((DdManager *)pNtk->pManFunc)) );
205  }
206  else
207  pNtk = pNtkTemp;
208  Abc_NtkMiterPrint( pNtk, "BDD building", clk, pParams->fVerbose );
209  }
210 
211  if ( RetValue < 0 )
212  {
213  if ( pParams->fVerbose )
214  {
215  printf( "Attempting SAT with conflict limit %d ...\n", pParams->nMiteringLimitLast );
216  fflush( stdout );
217  }
218  clk = Abc_Clock();
219  nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
220  RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)pParams->nMiteringLimitLast, (ABC_INT64_T)nInspectLimit, 0, NULL, NULL );
221  Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose );
222  }
223 
224  // assign the model if it was proved by rewriting (const 1 miter)
225  if ( RetValue == 0 && pNtk->pModel == NULL )
226  {
227  pNtk->pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) );
228  memset( pNtk->pModel, 0, sizeof(int) * Abc_NtkCiNum(pNtk) );
229  }
230  *ppNtk = pNtk;
231  return RetValue;
232 }
char * memset()
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static Abc_Ntk_t * Abc_NtkMiterFraig(Abc_Ntk_t *pNtk, int nBTLimit, ABC_INT64_T nInspLimit, int *pRetValue, int *pNumFails, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
Definition: abcProve.c:245
ABC_NAMESPACE_IMPL_START int Abc_NtkRefactor(Abc_Ntk_t *pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
DECLARATIONS ///.
Definition: abcRefactor.c:89
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static abctime Abc_Clock()
Definition: abc_global.h:279
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int * pModel
Definition: abc.h:198
ABC_DLL Abc_Ntk_t * Abc_NtkCollapse(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: abcCollapse.c:49
ABC_INT64_T nTotalInspectsMade
Definition: ivyFraig.c:137
void * pManFunc
Definition: abc.h:191
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_INT64_T nTotalBacktracksMade
Definition: ivyFraig.c:136
ABC_DLL int Abc_NtkRewrite(Abc_Ntk_t *pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable)
FUNCTION DEFINITIONS ///.
Definition: abcRewrite.c:61
static void Abc_NtkMiterPrint(Abc_Ntk_t *pNtk, char *pString, abctime clk, int fVerbose)
Definition: abcProve.c:311
ABC_DLL int Abc_NtkMiterSat(Abc_Ntk_t *pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
FUNCTION DEFINITIONS ///.
Definition: abcSat.c:53
ABC_INT64_T nTotalInspectLimit
Definition: ivyFraig.c:134
static int Counter
float nRewritingLimitMulti
Definition: ivyFraig.c:123
ABC_INT64_T nTotalBacktrackLimit
Definition: ivyFraig.c:133
ABC_DLL int Abc_NtkMiterIsConstant(Abc_Ntk_t *pMiter)
Definition: abcMiter.c:679
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
ABC_DLL Abc_Ntk_t * Abc_NtkBalance(Abc_Ntk_t *pNtk, int fDuplicate, int fSelective, int fUpdateLevel)
FUNCTION DEFINITIONS ///.
Definition: abcBalance.c:53
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
ABC_INT64_T abctime
Definition: abc_global.h:278
Abc_Ntk_t* Abc_NtkMiterRwsat ( Abc_Ntk_t pNtk)

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

Synopsis [Implements resynthesis for CEC.]

Description []

SideEffects []

SeeAlso []

Definition at line 332 of file abcProve.c.

333 {
334  Abc_Ntk_t * pNtkTemp;
335  Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
336  pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 ); Abc_NtkDelete( pNtkTemp );
337  Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
338  Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
339  return pNtk;
340 }
ABC_NAMESPACE_IMPL_START int Abc_NtkRefactor(Abc_Ntk_t *pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
DECLARATIONS ///.
Definition: abcRefactor.c:89
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL int Abc_NtkRewrite(Abc_Ntk_t *pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable)
FUNCTION DEFINITIONS ///.
Definition: abcRewrite.c:61
ABC_DLL Abc_Ntk_t * Abc_NtkBalance(Abc_Ntk_t *pNtk, int fDuplicate, int fSelective, int fUpdateLevel)
FUNCTION DEFINITIONS ///.
Definition: abcBalance.c:53
ABC_NAMESPACE_IMPL_START int Abc_NtkRefactor ( Abc_Ntk_t pNtk,
int  nNodeSizeMax,
int  nConeSizeMax,
int  fUpdateLevel,
int  fUseZeros,
int  fUseDcs,
int  fVerbose 
)

DECLARATIONS ///.

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

FileName [abcProve.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Proves the miter using AIG rewriting, FRAIGing, and SAT solving.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

DECLARATIONS ///.

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

Synopsis [Performs incremental resynthesis of the AIG.]

Description [Starting from each node, computes a reconvergence-driven cut, derives BDD of the cut function, constructs ISOP, factors the ISOP, and replaces the current implementation of the MFFC of the node by the new factored form, if the number of AIG nodes is reduced and the total number of levels of the AIG network is not increated. Returns the number of AIG nodes saved.]

SideEffects []

SeeAlso []

Definition at line 89 of file abcRefactor.c.

90 {
91  extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain );
92  ProgressBar * pProgress;
93  Abc_ManRef_t * pManRef;
94  Abc_ManCut_t * pManCut;
95  Dec_Graph_t * pFForm;
96  Vec_Ptr_t * vFanins;
97  Abc_Obj_t * pNode;
98  abctime clk, clkStart = Abc_Clock();
99  int i, nNodes;
100 
101  assert( Abc_NtkIsStrash(pNtk) );
102  // cleanup the AIG
104  // start the managers
105  pManCut = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, 1000 );
106  pManRef = Abc_NtkManRefStart( nNodeSizeMax, nConeSizeMax, fUseDcs, fVerbose );
107  pManRef->vLeaves = Abc_NtkManCutReadCutLarge( pManCut );
108  // compute the reverse levels if level update is requested
109  if ( fUpdateLevel )
110  Abc_NtkStartReverseLevels( pNtk, 0 );
111 
112  // resynthesize each node once
113  pManRef->nNodesBeg = Abc_NtkNodeNum(pNtk);
114  nNodes = Abc_NtkObjNumMax(pNtk);
115  pProgress = Extra_ProgressBarStart( stdout, nNodes );
116  Abc_NtkForEachNode( pNtk, pNode, i )
117  {
118  Extra_ProgressBarUpdate( pProgress, i, NULL );
119  // skip the constant node
120 // if ( Abc_NodeIsConst(pNode) )
121 // continue;
122  // skip persistant nodes
123  if ( Abc_NodeIsPersistant(pNode) )
124  continue;
125  // skip the nodes with many fanouts
126  if ( Abc_ObjFanoutNum(pNode) > 1000 )
127  continue;
128  // stop if all nodes have been tried once
129  if ( i >= nNodes )
130  break;
131  // compute a reconvergence-driven cut
132 clk = Abc_Clock();
133  vFanins = Abc_NodeFindCut( pManCut, pNode, fUseDcs );
134 pManRef->timeCut += Abc_Clock() - clk;
135  // evaluate this cut
136 clk = Abc_Clock();
137  pFForm = Abc_NodeRefactor( pManRef, pNode, vFanins, fUpdateLevel, fUseZeros, fUseDcs, fVerbose );
138 pManRef->timeRes += Abc_Clock() - clk;
139  if ( pFForm == NULL )
140  continue;
141  // acceptable replacement found, update the graph
142 clk = Abc_Clock();
143  Dec_GraphUpdateNetwork( pNode, pFForm, fUpdateLevel, pManRef->nLastGain );
144 pManRef->timeNtk += Abc_Clock() - clk;
145  Dec_GraphFree( pFForm );
146 // {
147 // extern int s_TotalChanges;
148 // s_TotalChanges++;
149 // }
150  }
151  Extra_ProgressBarStop( pProgress );
152 pManRef->timeTotal = Abc_Clock() - clkStart;
153  pManRef->nNodesEnd = Abc_NtkNodeNum(pNtk);
154 
155  // print statistics of the manager
156  if ( fVerbose )
157  Abc_NtkManRefPrintStats( pManRef );
158  // delete the managers
159  Abc_NtkManCutStop( pManCut );
160  Abc_NtkManRefStop( pManRef );
161  // put the nodes into the DFS order and reassign their IDs
162  Abc_NtkReassignIds( pNtk );
163 // Abc_AigCheckFaninOrder( pNtk->pManFunc );
164  // fix the levels
165  if ( fUpdateLevel )
166  Abc_NtkStopReverseLevels( pNtk );
167  else
168  Abc_NtkLevel( pNtk );
169  // check
170  if ( !Abc_NtkCheck( pNtk ) )
171  {
172  printf( "Abc_NtkRefactor: The network check has failed.\n" );
173  return 0;
174  }
175  return 1;
176 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static Dec_Graph_t * Abc_NodeRefactor(Abc_ManRef_t *p, Abc_Obj_t *pNode, Vec_Ptr_t *vFanins, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
Definition: abcRefactor.c:189
ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadCutLarge(Abc_ManCut_t *p)
Definition: abcReconv.c:637
void Dec_GraphUpdateNetwork(Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, int fUpdateLevel, int nGain)
Definition: decAbc.c:240
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static abctime Abc_Clock()
Definition: abc_global.h:279
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL void Abc_NtkStopReverseLevels(Abc_Ntk_t *pNtk)
Definition: abcTiming.c:1190
ABC_DLL Vec_Ptr_t * Abc_NodeFindCut(Abc_ManCut_t *p, Abc_Obj_t *pRoot, int fContain)
Definition: abcReconv.c:253
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1769
void * pManFunc
Definition: abc.h:191
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
DECLARATIONS ///.
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition: abcAig.c:194
ABC_DLL void Abc_NtkStartReverseLevels(Abc_Ntk_t *pNtk, int nMaxLevelIncrease)
Definition: abcTiming.c:1162
void Extra_ProgressBarStop(ProgressBar *p)
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NodeIsPersistant(Abc_Obj_t *pNode)
Definition: abc.h:401
static void Abc_NtkManRefPrintStats(Abc_ManRef_t *p)
Definition: abcRefactor.c:367
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static Abc_ManRef_t * Abc_NtkManRefStart(int nNodeSizeMax, int nConeSizeMax, int fUseDcs, int fVerbose)
Definition: abcRefactor.c:318
ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart(int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop)
Definition: abcReconv.c:588
static void Dec_GraphFree(Dec_Graph_t *pGraph)
Definition: dec.h:307
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
ABC_DLL void Abc_NtkManCutStop(Abc_ManCut_t *p)
Definition: abcReconv.c:616
ABC_INT64_T abctime
Definition: abc_global.h:278
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
static void Abc_NtkManRefStop(Abc_ManRef_t *p)
Definition: abcRefactor.c:348
DECLARATIONS ///.
Definition: abcReconv.c:31
typedefABC_NAMESPACE_IMPL_START struct Abc_ManRef_t_ Abc_ManRef_t
DECLARATIONS ///.
Definition: abcRefactor.c:32