#include "abc.h"
Go to the source code of this file.
Functions | |
static void | Abc_NtkModelToVector (Abc_Ntk_t *pNtk, Vec_Int_t *vPiValues) |
static void | Abc_NtkVectorClearPars (Vec_Int_t *vPiValues, int nPars) |
static void | Abc_NtkVectorClearVars (Abc_Ntk_t *pNtk, Vec_Int_t *vPiValues, int nPars) |
static void | Abc_NtkVectorPrintPars (Vec_Int_t *vPiValues, int nPars) |
static void | Abc_NtkVectorPrintVars (Abc_Ntk_t *pNtk, Vec_Int_t *vPiValues, int nPars) |
void | Abc_NtkQbf (Abc_Ntk_t *pNtk, int nPars, int fVerbose) |
CFile****************************************************************
FileName [abcQbf.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Implementation of a simple QBF solver.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
] DECLARATIONS ///
Function*************************************************************
Synopsis [Translates model into the vector of values.]
Description []
SideEffects []
SeeAlso []
Definition at line 176 of file abcQbf.c.
00177 { 00178 int * pModel, i; 00179 pModel = pNtk->pModel; 00180 for ( i = 0; i < Abc_NtkPiNum(pNtk); i++ ) 00181 Vec_IntWriteEntry( vPiValues, i, pModel[i] ); 00182 }
void Abc_NtkQbf | ( | Abc_Ntk_t * | pNtk, | |
int | nPars, | |||
int | fVerbose | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Solve the QBF problem EpAx[M(p,x)].]
Description [Variables p go first, followed by variable x. The number of parameters is nPars. The miter is in pNtk. The miter expresses EQUALITY of the implementation and spec.]
SideEffects []
SeeAlso []
Definition at line 58 of file abcQbf.c.
00059 { 00060 Abc_Ntk_t * pNtkVer, * pNtkSyn, * pNtkSyn2, * pNtkTemp; 00061 Vec_Int_t * vPiValues; 00062 int clkTotal = clock(), clkS, clkV; 00063 int nIters, nIterMax = 500, nInputs, RetValue, fFound = 0; 00064 00065 assert( Abc_NtkIsStrash(pNtk) ); 00066 assert( Abc_NtkIsComb(pNtk) ); 00067 assert( Abc_NtkPoNum(pNtk) == 1 ); 00068 assert( nPars > 0 && nPars < Abc_NtkPiNum(pNtk) ); 00069 assert( Abc_NtkPiNum(pNtk)-nPars < 32 ); 00070 nInputs = Abc_NtkPiNum(pNtk) - nPars; 00071 00072 // initialize the synthesized network with 0000-combination 00073 vPiValues = Vec_IntStart( Abc_NtkPiNum(pNtk) ); 00074 Abc_NtkVectorClearPars( vPiValues, nPars ); 00075 pNtkSyn = Abc_NtkMiterCofactor( pNtk, vPiValues ); 00076 if ( fVerbose ) 00077 { 00078 printf( "Iter %2d : ", 0 ); 00079 printf( "AIG = %6d ", Abc_NtkNodeNum(pNtkSyn) ); 00080 Abc_NtkVectorPrintVars( pNtk, vPiValues, nPars ); 00081 printf( "\n" ); 00082 } 00083 00084 // iteratively solve 00085 for ( nIters = 0; nIters < nIterMax; nIters++ ) 00086 { 00087 // solve the synthesis instance 00088 clkS = clock(); 00089 RetValue = Abc_NtkMiterSat( pNtkSyn, 0, 0, 0, NULL, NULL ); 00090 clkS = clock() - clkS; 00091 if ( RetValue == 0 ) 00092 Abc_NtkModelToVector( pNtkSyn, vPiValues ); 00093 if ( RetValue == 1 ) 00094 { 00095 break; 00096 } 00097 if ( RetValue == -1 ) 00098 { 00099 printf( "Synthesis timed out.\n" ); 00100 break; 00101 } 00102 // there is a counter-example 00103 00104 // construct the verification instance 00105 Abc_NtkVectorClearVars( pNtk, vPiValues, nPars ); 00106 pNtkVer = Abc_NtkMiterCofactor( pNtk, vPiValues ); 00107 // complement the output 00108 Abc_ObjXorFaninC( Abc_NtkPo(pNtkVer,0), 0 ); 00109 00110 // solve the verification instance 00111 clkV = clock(); 00112 RetValue = Abc_NtkMiterSat( pNtkVer, 0, 0, 0, NULL, NULL ); 00113 clkV = clock() - clkV; 00114 if ( RetValue == 0 ) 00115 Abc_NtkModelToVector( pNtkVer, vPiValues ); 00116 Abc_NtkDelete( pNtkVer ); 00117 if ( RetValue == 1 ) 00118 { 00119 fFound = 1; 00120 break; 00121 } 00122 if ( RetValue == -1 ) 00123 { 00124 printf( "Verification timed out.\n" ); 00125 break; 00126 } 00127 // there is a counter-example 00128 00129 // create a new synthesis network 00130 Abc_NtkVectorClearPars( vPiValues, nPars ); 00131 pNtkSyn2 = Abc_NtkMiterCofactor( pNtk, vPiValues ); 00132 // add to the synthesis instance 00133 pNtkSyn = Abc_NtkMiterAnd( pNtkTemp = pNtkSyn, pNtkSyn2, 0, 0 ); 00134 Abc_NtkDelete( pNtkSyn2 ); 00135 Abc_NtkDelete( pNtkTemp ); 00136 00137 if ( fVerbose ) 00138 { 00139 printf( "Iter %2d : ", nIters+1 ); 00140 printf( "AIG = %6d ", Abc_NtkNodeNum(pNtkSyn) ); 00141 Abc_NtkVectorPrintVars( pNtk, vPiValues, nPars ); 00142 printf( " " ); 00143 // PRTn( "Syn", clkS ); 00144 PRT( "Ver", clkV ); 00145 } 00146 } 00147 Abc_NtkDelete( pNtkSyn ); 00148 // report the results 00149 if ( fFound ) 00150 { 00151 printf( "Parameters: " ); 00152 Abc_NtkVectorPrintPars( vPiValues, nPars ); 00153 printf( "\n" ); 00154 printf( "Solved after %d interations. ", nIters ); 00155 } 00156 else if ( nIters == nIterMax ) 00157 printf( "Unsolved after %d interations. ", nIters ); 00158 else 00159 printf( "Implementation does not exist. " ); 00160 PRT( "Total runtime", clock() - clkTotal ); 00161 Vec_IntFree( vPiValues ); 00162 }
void Abc_NtkVectorClearPars | ( | Vec_Int_t * | vPiValues, | |
int | nPars | |||
) | [static] |
Function*************************************************************
Synopsis [Clears parameters.]
Description []
SideEffects []
SeeAlso []
Definition at line 195 of file abcQbf.c.
00196 { 00197 int i; 00198 for ( i = 0; i < nPars; i++ ) 00199 Vec_IntWriteEntry( vPiValues, i, -1 ); 00200 }
Function*************************************************************
Synopsis [Clears variables.]
Description []
SideEffects []
SeeAlso []
Definition at line 213 of file abcQbf.c.
00214 { 00215 int i; 00216 for ( i = nPars; i < Abc_NtkPiNum(pNtk); i++ ) 00217 Vec_IntWriteEntry( vPiValues, i, -1 ); 00218 }
void Abc_NtkVectorPrintPars | ( | Vec_Int_t * | vPiValues, | |
int | nPars | |||
) | [static] |
Function*************************************************************
Synopsis [Clears variables.]
Description []
SideEffects []
SeeAlso []
Definition at line 231 of file abcQbf.c.
00232 { 00233 int i; 00234 for ( i = 0; i < nPars; i++ ) 00235 printf( "%d", Vec_IntEntry(vPiValues,i) ); 00236 }
Function*************************************************************
Synopsis [Clears variables.]
Description []
SideEffects []
SeeAlso []
Definition at line 249 of file abcQbf.c.
00250 { 00251 int i; 00252 for ( i = nPars; i < Abc_NtkPiNum(pNtk); i++ ) 00253 printf( "%d", Vec_IntEntry(vPiValues,i) ); 00254 }