abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcSense.c File Reference
#include "base/abc/abc.h"
#include "proof/fraig/fraig.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Abc_Obj_t
Abc_NtkSensitivityMiter_rec (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
 DECLARATIONS ///. More...
 
Abc_Ntk_tAbc_NtkSensitivityMiter (Abc_Ntk_t *pNtk, int iVar)
 
Vec_Int_tAbc_NtkSensitivity (Abc_Ntk_t *pNtk, int nConfLim, int fVerbose)
 

Function Documentation

Vec_Int_t* Abc_NtkSensitivity ( Abc_Ntk_t pNtk,
int  nConfLim,
int  fVerbose 
)

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

Synopsis [Computing sensitivity of POs to POs under constraints.]

Description [The input network is a combinatonal AIG. The last output is a constraint. The procedure returns the list of number of PIs, such that at least one PO depends on this PI, under the constraint.]

SideEffects []

SeeAlso []

Definition at line 160 of file abcSense.c.

161 {
162  ProgressBar * pProgress;
163  Prove_Params_t Params, * pParams = &Params;
164  Vec_Int_t * vResult = NULL;
165  Abc_Ntk_t * pMiter;
166  Abc_Obj_t * pObj;
167  int RetValue, i;
168  assert( Abc_NtkIsStrash(pNtk) );
169  assert( Abc_NtkLatchNum(pNtk) == 0 );
170  // set up solving parameters
171  Prove_ParamsSetDefault( pParams );
172  pParams->nItersMax = 3;
173  pParams->nMiteringLimitLast = nConfLim;
174  // iterate through the PIs
175  vResult = Vec_IntAlloc( 100 );
176  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCiNum(pNtk) );
177  Abc_NtkForEachCi( pNtk, pObj, i )
178  {
179  Extra_ProgressBarUpdate( pProgress, i, NULL );
180  // generate the sensitivity miter
181  pMiter = Abc_NtkSensitivityMiter( pNtk, i );
182  // solve the miter using CEC engine
183  RetValue = Abc_NtkIvyProve( &pMiter, pParams );
184  if ( RetValue == -1 ) // undecided
185  Vec_IntPush( vResult, i );
186  else if ( RetValue == 0 )
187  {
188  int * pSimInfo = Abc_NtkVerifySimulatePattern( pMiter, pMiter->pModel );
189  if ( pSimInfo[0] != 1 )
190  printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
191 // else
192 // printf( "Networks are NOT EQUIVALENT.\n" );
193  ABC_FREE( pSimInfo );
194  Vec_IntPush( vResult, i );
195  }
196  Abc_NtkDelete( pMiter );
197  }
198  Extra_ProgressBarStop( pProgress );
199  if ( fVerbose )
200  {
201  printf( "The outputs are sensitive to %d (out of %d) inputs:\n",
202  Vec_IntSize(vResult), Abc_NtkCiNum(pNtk) );
203  Vec_IntForEachEntry( vResult, RetValue, i )
204  printf( "%d ", RetValue );
205  printf( "\n" );
206  }
207  return vResult;
208 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
void Prove_ParamsSetDefault(Prove_Params_t *pParams)
FUNCTION DEFINITIONS ///.
Definition: fraigMan.c:46
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int * pModel
Definition: abc.h:198
DECLARATIONS ///.
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL int Abc_NtkIvyProve(Abc_Ntk_t **ppNtk, void *pPars)
Definition: abcIvy.c:498
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Extra_ProgressBarStop(ProgressBar *p)
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define ABC_FREE(obj)
Definition: abc_global.h:232
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Abc_Ntk_t * Abc_NtkSensitivityMiter(Abc_Ntk_t *pNtk, int iVar)
Definition: abcSense.c:67
ABC_DLL int * Abc_NtkVerifySimulatePattern(Abc_Ntk_t *pNtk, int *pModel)
Definition: abcVerify.c:686
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Abc_Ntk_t* Abc_NtkSensitivityMiter ( Abc_Ntk_t pNtk,
int  iVar 
)

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

Synopsis [Creates miter for the sensitivity analysis.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file abcSense.c.

68 {
69  Abc_Ntk_t * pMiter;
70  Vec_Ptr_t * vNodes;
71  Abc_Obj_t * pObj, * pNext, * pFanin, * pOutput, * pObjNew;
72  int i;
73  assert( Abc_NtkIsStrash(pNtk) );
74  assert( iVar < Abc_NtkCiNum(pNtk) );
75 
76  // duplicate the network
78  pMiter->pName = Extra_UtilStrsav(pNtk->pName);
79  pMiter->pSpec = Extra_UtilStrsav(pNtk->pSpec);
80 
81  // assign the PIs
82  Abc_NtkCleanCopy( pNtk );
83  Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pMiter);
84  Abc_AigConst1(pNtk)->pData = Abc_AigConst1(pMiter);
85  Abc_NtkForEachCi( pNtk, pObj, i )
86  {
87  pObj->pCopy = Abc_NtkCreatePi( pMiter );
88  pObj->pData = pObj->pCopy;
89  }
90  Abc_NtkAddDummyPiNames( pMiter );
91 
92  // assign the cofactors of the CI node to be constants
93  pObj = Abc_NtkCi( pNtk, iVar );
94  pObj->pCopy = Abc_ObjNot( Abc_AigConst1(pMiter) );
95  pObj->pData = Abc_AigConst1(pMiter);
96 
97  // collect the internal nodes
98  vNodes = Abc_NtkDfsReverseNodes( pNtk, &pObj, 1 );
99  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
100  {
101  for ( pNext = pObj? pObj->pCopy : pObj; pObj; pObj = pNext, pNext = pObj? pObj->pCopy : pObj )
102  {
103  pFanin = Abc_ObjFanin0(pObj);
104  if ( !Abc_NodeIsTravIdCurrent(pFanin) )
105  pFanin->pData = Abc_NtkSensitivityMiter_rec( pMiter, pFanin );
106  pFanin = Abc_ObjFanin1(pObj);
107  if ( !Abc_NodeIsTravIdCurrent(pFanin) )
108  pFanin->pData = Abc_NtkSensitivityMiter_rec( pMiter, pFanin );
109  pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
110  pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, Abc_ObjChild0Data(pObj), Abc_ObjChild1Data(pObj) );
111  }
112  }
113  Vec_PtrFree( vNodes );
114 
115  // update the affected COs
116  pOutput = Abc_ObjNot( Abc_AigConst1(pMiter) );
117  Abc_NtkForEachCo( pNtk, pObj, i )
118  {
119  if ( !Abc_NodeIsTravIdCurrent(pObj) )
120  continue;
121  // get the result of quantification
122  if ( i == Abc_NtkCoNum(pNtk) - 1 )
123  {
124  pOutput = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, pOutput, Abc_ObjChild0Data(pObj) );
125  pOutput = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, pOutput, Abc_ObjChild0Copy(pObj) );
126  }
127  else
128  {
129  pNext = Abc_AigXor( (Abc_Aig_t *)pMiter->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
130  pOutput = Abc_AigOr( (Abc_Aig_t *)pMiter->pManFunc, pOutput, pNext );
131  }
132  }
133  // add the PO node and name
134  pObjNew = Abc_NtkCreatePo(pMiter);
135  Abc_ObjAddFanin( pObjNew, pOutput );
136  Abc_ObjAssignName( pObjNew, "miter", NULL );
137  // make sure everything is okay
138  if ( !Abc_NtkCheck( pMiter ) )
139  {
140  printf( "Abc_NtkSensitivityMiter: The network check has failed.\n" );
141  Abc_NtkDelete( pMiter );
142  return NULL;
143  }
144  return pMiter;
145 }
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 Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
ABC_DLL Abc_Obj_t * Abc_AigOr(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:719
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static Abc_Obj_t * Abc_ObjChild1Copy(Abc_Obj_t *pObj)
Definition: abc.h:387
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
DECLARATIONS ///.
Definition: abcAig.c:52
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
static Abc_Obj_t * Abc_ObjChild1Data(Abc_Obj_t *pObj)
Definition: abc.h:389
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:735
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static Abc_Obj_t * Abc_ObjChild0Copy(Abc_Obj_t *pObj)
Definition: abc.h:386
Abc_Obj_t * pCopy
Definition: abc.h:148
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_NtkSensitivityMiter_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcSense.c:46
char * pSpec
Definition: abc.h:159
static Abc_Obj_t * Abc_ObjChild0Data(Abc_Obj_t *pObj)
Definition: abc.h:388
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_DLL Vec_Ptr_t * Abc_NtkDfsReverseNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:263
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:378
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
ABC_NAMESPACE_IMPL_START Abc_Obj_t* Abc_NtkSensitivityMiter_rec ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pNode 
)

DECLARATIONS ///.

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

FileName [abcSense.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Copies the topmost levels of the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file abcSense.c.

47 {
48  assert( !Abc_ObjIsComplement(pNode) );
49  if ( pNode->pCopy )
50  return pNode->pCopy;
51  Abc_NtkSensitivityMiter_rec( pNtkNew, Abc_ObjFanin0(pNode) );
52  Abc_NtkSensitivityMiter_rec( pNtkNew, Abc_ObjFanin1(pNode) );
53  return pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
54 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static Abc_Obj_t * Abc_ObjChild1Copy(Abc_Obj_t *pObj)
Definition: abc.h:387
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
DECLARATIONS ///.
Definition: abcAig.c:52
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static Abc_Obj_t * Abc_ObjChild0Copy(Abc_Obj_t *pObj)
Definition: abc.h:386
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_NtkSensitivityMiter_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcSense.c:46
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322