ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcSense.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "proof/fraig/fraig.h"
23
25
26
30
34
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}
55
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}
146
160Vec_Int_t * Abc_NtkSensitivity( Abc_Ntk_t * pNtk, int nConfLim, int fVerbose )
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}
209
213
214
216
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_NtkSensitivityMiter_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcSense.c:46
Abc_Ntk_t * Abc_NtkSensitivityMiter(Abc_Ntk_t *pNtk, int iVar)
Definition abcSense.c:67
Vec_Int_t * Abc_NtkSensitivity(Abc_Ntk_t *pNtk, int nConfLim, int fVerbose)
Definition abcSense.c:160
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL int Abc_NtkIvyProve(Abc_Ntk_t **ppNtk, void *pPars)
Definition abcIvy.c:503
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:735
ABC_DLL Vec_Ptr_t * Abc_NtkDfsReverseNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:294
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
@ ABC_NTK_STRASH
Definition abc.h:58
ABC_DLL int * Abc_NtkVerifySimulatePattern(Abc_Ntk_t *pNtk, int *pModel)
Definition abcVerify.c:696
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
ABC_DLL Abc_Obj_t * Abc_AigOr(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:719
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
@ ABC_FUNC_AIG
Definition abc.h:67
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
void Extra_ProgressBarStop(ProgressBar *p)
char * Extra_UtilStrsav(const char *s)
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
void Prove_ParamsSetDefault(Prove_Params_t *pParams)
FUNCTION DEFINITIONS ///.
Definition fraigMan.c:46
struct Prove_ParamsStruct_t_ Prove_Params_t
Definition ivyFraig.c:108
char * pName
Definition abc.h:158
void * pManFunc
Definition abc.h:191
int * pModel
Definition abc.h:198
char * pSpec
Definition abc.h:159
void * pData
Definition abc.h:145
Abc_Obj_t * pCopy
Definition abc.h:148
#define assert(ex)
Definition util_old.h:213
#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