ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
absPth.c
Go to the documentation of this file.
1
20
21#include "abs.h"
22#include "proof/pdr/pdr.h"
23#include "proof/ssw/ssw.h"
24
25
26#ifdef ABC_USE_PTHREADS
27
28#ifdef _WIN32
29#include "../lib/pthread.h"
30#else
31#include <pthread.h>
32#include <unistd.h>
33#endif
34
35#endif
36
38
42
43#ifndef ABC_USE_PTHREADS
44
45void Gia_GlaProveAbsracted( Gia_Man_t * p, int fSimpProver, int fVerbose ) {}
46void Gia_GlaProveCancel( int fVerbose ) {}
47int Gia_GlaProveCheck( int fVerbose ) { return 0; }
48
49#else // pthreads are used
50
51// information given to the thread
52typedef struct Abs_ThData_t_
53{
54 Aig_Man_t * pAig;
55 int fVerbose;
56 int RunId;
57} Abs_ThData_t;
58
59// mutext to control access to shared variables
60pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
61static volatile int g_nRunIds = 0; // the number of the last prover instance
62static volatile int g_fAbstractionProved = 0; // set to 1 when prover successed to prove
63
64// call back procedure for PDR
65int Abs_CallBackToStop( int RunId ) { assert( RunId <= g_nRunIds ); return RunId < g_nRunIds; }
66
67// test procedure to replace PDR
68int Pdr_ManSolve_test( Aig_Man_t * pAig, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
69{
70 char * p = ABC_ALLOC( char, 111 );
71 while ( 1 )
72 {
73 if ( pPars->pFuncStop && pPars->pFuncStop(pPars->RunId) )
74 break;
75 }
76 ABC_FREE( p );
77 return -1;
78}
79
83
95void * Abs_ProverThread( void * pArg )
96{
97 Abs_ThData_t * pThData = (Abs_ThData_t *)pArg;
98 Pdr_Par_t Pars, * pPars = &Pars;
99 int RetValue, status;
100 // call PDR
102 pPars->fSilent = 1;
103 pPars->RunId = pThData->RunId;
104 pPars->pFuncStop = Abs_CallBackToStop;
105 RetValue = Pdr_ManSolve( pThData->pAig, pPars );
106 // update the result
107 if ( RetValue == 1 )
108 {
109 status = pthread_mutex_lock(&g_mutex); assert( status == 0 );
110 g_fAbstractionProved = 1;
111 status = pthread_mutex_unlock(&g_mutex); assert( status == 0 );
112 }
113 // quit this thread
114 if ( pThData->fVerbose )
115 {
116 if ( RetValue == 1 )
117 Abc_Print( 1, "Proved abstraction %d.\n", pThData->RunId );
118 else if ( RetValue == 0 )
119 Abc_Print( 1, "Disproved abstraction %d.\n", pThData->RunId );
120 else if ( RetValue == -1 )
121 Abc_Print( 1, "Cancelled abstraction %d.\n", pThData->RunId );
122 else assert( 0 );
123 }
124 // free memory
125 Aig_ManStop( pThData->pAig );
126 ABC_FREE( pThData );
127 // quit this thread
128 pthread_exit( NULL );
129 assert(0);
130 return NULL;
131}
132void Gia_GlaProveAbsracted( Gia_Man_t * pGia, int fSimpProver, int fVerbose )
133{
134 extern Aig_Man_t * Dar_ManRwsat( Aig_Man_t * pAig, int fBalance, int fVerbose );
135 Abs_ThData_t * pThData;
136 Ssw_Pars_t Pars, * pPars = &Pars;
137 Aig_Man_t * pAig, * pTemp;
138 Gia_Man_t * pAbs;
139 pthread_t ProverThread;
140 int status;
141 // disable verbosity
142// fVerbose = 0;
143 // create abstraction
144 assert( pGia->vGateClasses != NULL );
145 pAbs = Gia_ManDupAbsGates( pGia, pGia->vGateClasses );
146 Gia_ManCleanValue( pGia );
147 pAig = Gia_ManToAigSimple( pAbs );
148 Gia_ManStop( pAbs );
149 // simplify abstraction
150 if ( fSimpProver )
151 {
153 pPars->nFramesK = 4;
154 pAig = Ssw_SignalCorrespondence( pTemp = pAig, pPars );
155//printf( "\n" );
156//Aig_ManPrintStats( pTemp );
157//Aig_ManPrintStats( pAig );
158 Aig_ManStop( pTemp );
159 }
160 // synthesize abstraction
161// pAig = Dar_ManRwsat( pTemp = pAig, 0, 0 );
162// Aig_ManStop( pTemp );
163 // reset the proof
164 status = pthread_mutex_lock(&g_mutex); assert( status == 0 );
165 g_fAbstractionProved = 0;
166 status = pthread_mutex_unlock(&g_mutex); assert( status == 0 );
167 // collect thread data
168 pThData = ABC_CALLOC( Abs_ThData_t, 1 );
169 pThData->pAig = pAig;
170 pThData->fVerbose = fVerbose;
171 status = pthread_mutex_lock(&g_mutex); assert( status == 0 );
172 pThData->RunId = ++g_nRunIds;
173 status = pthread_mutex_unlock(&g_mutex); assert( status == 0 );
174 // create thread
175 if ( fVerbose ) Abc_Print( 1, "\nTrying to prove abstraction %d.\n", pThData->RunId );
176 status = pthread_create( &ProverThread, NULL, Abs_ProverThread, pThData );
177 assert( status == 0 );
178}
179void Gia_GlaProveCancel( int fVerbose )
180{
181 int status;
182 status = pthread_mutex_lock(&g_mutex); assert( status == 0 );
183 g_nRunIds++;
184 status = pthread_mutex_unlock(&g_mutex); assert( status == 0 );
185}
186int Gia_GlaProveCheck( int fVerbose )
187{
188 int status;
189 if ( g_fAbstractionProved == 0 )
190 return 0;
191 status = pthread_mutex_lock(&g_mutex); assert( status == 0 );
192 g_fAbstractionProved = 0;
193 status = pthread_mutex_unlock(&g_mutex); assert( status == 0 );
194 return 1;
195}
196
197#endif // pthreads are used
198
202
203
205
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START void Gia_GlaProveAbsracted(Gia_Man_t *p, int fSimpProver, int fVerbose)
DECLARATIONS ///.
Definition absPth.c:45
void Gia_GlaProveCancel(int fVerbose)
Definition absPth.c:46
int Gia_GlaProveCheck(int fVerbose)
Definition absPth.c:47
Gia_Man_t * Gia_ManDupAbsGates(Gia_Man_t *p, Vec_Int_t *vGateClasses)
Definition absDup.c:220
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
Definition darScript.c:71
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Cube * p
Definition exorList.c:222
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition giaAig.c:408
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ManCleanValue(Gia_Man_t *p)
Definition giaUtil.c:351
void Pdr_ManSetDefaultParams(Pdr_Par_t *pPars)
MACRO DEFINITIONS ///.
Definition pdrCore.c:50
typedefABC_NAMESPACE_HEADER_START struct Pdr_Par_t_ Pdr_Par_t
INCLUDES ///.
Definition pdr.h:40
int Pdr_ManSolve(Aig_Man_t *p, Pdr_Par_t *pPars)
Definition pdrCore.c:1765
void Ssw_ManSetDefaultParams(Ssw_Pars_t *p)
DECLARATIONS ///.
Definition sswCore.c:45
typedefABC_NAMESPACE_HEADER_START struct Ssw_Pars_t_ Ssw_Pars_t
INCLUDES ///.
Definition ssw.h:40
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
Definition sswCore.c:436
Vec_Int_t * vGateClasses
Definition gia.h:157
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
#define assert(ex)
Definition util_old.h:213