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

Go to the source code of this file.

Data Structures

struct  ABC_ManagerStruct_t
 

Macros

#define ABC_DEFAULT_CONF_LIMIT   0
 DECLARATIONS ///. More...
 
#define ABC_DEFAULT_IMP_LIMIT   0
 

Functions

static CSAT_Target_ResultTABC_TargetResAlloc (int nVars)
 
static char * ABC_GetNodeName (ABC_Manager mng, Abc_Obj_t *pNode)
 
void Abc_Start ()
 DECLARATIONS ///. More...
 
void Abc_Stop ()
 
int Io_WriteBench (Abc_Ntk_t *pNtk, const char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
ABC_Manager ABC_InitManager ()
 FUNCTION DEFINITIONS ///. More...
 
void ABC_ReleaseManager (ABC_Manager mng)
 
void ABC_SetSolveOption (ABC_Manager mng, enum CSAT_OptionT option)
 
void ABC_UseOnlyCoreSatSolver (ABC_Manager mng)
 
int ABC_AddGate (ABC_Manager mng, enum GateType type, char *name, int nofi, char **fanins, int dc_attr)
 
void ABC_Network_Finalize (ABC_Manager mng)
 
int ABC_Check_Integrity (ABC_Manager mng)
 
void ABC_SetTimeLimit (ABC_Manager mng, int runtime)
 
void ABC_SetLearnLimit (ABC_Manager mng, int num)
 
void ABC_SetLearnBacktrackLimit (ABC_Manager mng, int num)
 
void ABC_SetSolveBacktrackLimit (ABC_Manager mng, int num)
 
void ABC_SetSolveImplicationLimit (ABC_Manager mng, int num)
 
void ABC_SetTotalBacktrackLimit (ABC_Manager mng, ABC_UINT64_T num)
 
void ABC_SetTotalInspectLimit (ABC_Manager mng, ABC_UINT64_T num)
 
ABC_UINT64_T ABC_GetTotalBacktracksMade (ABC_Manager mng)
 
ABC_UINT64_T ABC_GetTotalInspectsMade (ABC_Manager mng)
 
void ABC_EnableDump (ABC_Manager mng, char *dump_file)
 
int ABC_AddTarget (ABC_Manager mng, int nog, char **names, int *values)
 
void ABC_SolveInit (ABC_Manager mng)
 
void ABC_AnalyzeTargets (ABC_Manager mng)
 
enum CSAT_StatusT ABC_Solve (ABC_Manager mng)
 
CSAT_Target_ResultTABC_Get_Target_Result (ABC_Manager mng, int TargetID)
 
void ABC_Dump_Bench_File (ABC_Manager mng)
 
void ABC_TargetResFree (CSAT_Target_ResultT *p)
 

Macro Definition Documentation

#define ABC_DEFAULT_CONF_LIMIT   0

DECLARATIONS ///.

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

FileName [csat_apis.h]

PackageName [Interface to CSAT.]

Synopsis [APIs, enums, and data structures expected from the use of CSAT.]

Author [Alan Mishchenko alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 28, 2005]

Revision [

Id:
csat_apis.h,v 1.00 2005/08/28 00:00:00 alanmi Exp

]

Definition at line 32 of file csat_apis.c.

#define ABC_DEFAULT_IMP_LIMIT   0

Definition at line 33 of file csat_apis.c.

Function Documentation

int ABC_AddGate ( ABC_Manager  mng,
enum GateType  type,
char *  name,
int  nofi,
char **  fanins,
int  dc_attr 
)

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

Synopsis [Adds a gate to the circuit.]

Description [The meaning of the parameters are: type: the type of the gate to be added name: the name of the gate to be added, name should be unique in a circuit. nofi: number of fanins of the gate to be added; fanins: the name array of fanins of the gate to be added.]

SideEffects []

SeeAlso []

Definition at line 175 of file csat_apis.c.

176 {
177  Abc_Obj_t * pObj = NULL; // Suppress "might be used uninitialized"
178  Abc_Obj_t * pFanin;
179  char * pSop = NULL; // Suppress "might be used uninitialized"
180  char * pNewName;
181  int i;
182 
183  // save the name in the local memory manager
184  pNewName = Mem_FlexEntryFetch( mng->pMmNames, strlen(name) + 1 );
185  strcpy( pNewName, name );
186  name = pNewName;
187 
188  // consider different cases, create the node, and map the node into the name
189  switch( type )
190  {
191  case CSAT_BPI:
192  case CSAT_BPPI:
193  if ( nofi != 0 )
194  { printf( "ABC_AddGate: The PI/PPI gate \"%s\" has fanins.\n", name ); return 0; }
195  // create the PI
196  pObj = Abc_NtkCreatePi( mng->pNtk );
197  stmm_insert( mng->tNode2Name, (char *)pObj, name );
198  break;
199  case CSAT_CONST:
200  case CSAT_BAND:
201  case CSAT_BNAND:
202  case CSAT_BOR:
203  case CSAT_BNOR:
204  case CSAT_BXOR:
205  case CSAT_BXNOR:
206  case CSAT_BINV:
207  case CSAT_BBUF:
208  // create the node
209  pObj = Abc_NtkCreateNode( mng->pNtk );
210  // create the fanins
211  for ( i = 0; i < nofi; i++ )
212  {
213  if ( !stmm_lookup( mng->tName2Node, fanins[i], (char **)&pFanin ) )
214  { printf( "ABC_AddGate: The fanin gate \"%s\" is not in the network.\n", fanins[i] ); return 0; }
215  Abc_ObjAddFanin( pObj, pFanin );
216  }
217  // create the node function
218  switch( type )
219  {
220  case CSAT_CONST:
221  if ( nofi != 0 )
222  { printf( "ABC_AddGate: The constant gate \"%s\" has fanins.\n", name ); return 0; }
223  pSop = Abc_SopCreateConst1( (Mem_Flex_t *)mng->pNtk->pManFunc );
224  break;
225  case CSAT_BAND:
226  if ( nofi < 1 )
227  { printf( "ABC_AddGate: The AND gate \"%s\" no fanins.\n", name ); return 0; }
228  pSop = Abc_SopCreateAnd( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi, NULL );
229  break;
230  case CSAT_BNAND:
231  if ( nofi < 1 )
232  { printf( "ABC_AddGate: The NAND gate \"%s\" no fanins.\n", name ); return 0; }
233  pSop = Abc_SopCreateNand( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi );
234  break;
235  case CSAT_BOR:
236  if ( nofi < 1 )
237  { printf( "ABC_AddGate: The OR gate \"%s\" no fanins.\n", name ); return 0; }
238  pSop = Abc_SopCreateOr( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi, NULL );
239  break;
240  case CSAT_BNOR:
241  if ( nofi < 1 )
242  { printf( "ABC_AddGate: The NOR gate \"%s\" no fanins.\n", name ); return 0; }
243  pSop = Abc_SopCreateNor( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi );
244  break;
245  case CSAT_BXOR:
246  if ( nofi < 1 )
247  { printf( "ABC_AddGate: The XOR gate \"%s\" no fanins.\n", name ); return 0; }
248  if ( nofi > 2 )
249  { printf( "ABC_AddGate: The XOR gate \"%s\" has more than two fanins.\n", name ); return 0; }
250  pSop = Abc_SopCreateXor( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi );
251  break;
252  case CSAT_BXNOR:
253  if ( nofi < 1 )
254  { printf( "ABC_AddGate: The XNOR gate \"%s\" no fanins.\n", name ); return 0; }
255  if ( nofi > 2 )
256  { printf( "ABC_AddGate: The XNOR gate \"%s\" has more than two fanins.\n", name ); return 0; }
257  pSop = Abc_SopCreateNxor( (Mem_Flex_t *)mng->pNtk->pManFunc, nofi );
258  break;
259  case CSAT_BINV:
260  if ( nofi != 1 )
261  { printf( "ABC_AddGate: The inverter gate \"%s\" does not have exactly one fanin.\n", name ); return 0; }
262  pSop = Abc_SopCreateInv( (Mem_Flex_t *)mng->pNtk->pManFunc );
263  break;
264  case CSAT_BBUF:
265  if ( nofi != 1 )
266  { printf( "ABC_AddGate: The buffer gate \"%s\" does not have exactly one fanin.\n", name ); return 0; }
267  pSop = Abc_SopCreateBuf( (Mem_Flex_t *)mng->pNtk->pManFunc );
268  break;
269  default :
270  break;
271  }
272  Abc_ObjSetData( pObj, pSop );
273  break;
274  case CSAT_BPPO:
275  case CSAT_BPO:
276  if ( nofi != 1 )
277  { printf( "ABC_AddGate: The PO/PPO gate \"%s\" does not have exactly one fanin.\n", name ); return 0; }
278  // create the PO
279  pObj = Abc_NtkCreatePo( mng->pNtk );
280  stmm_insert( mng->tNode2Name, (char *)pObj, name );
281  // connect to the PO fanin
282  if ( !stmm_lookup( mng->tName2Node, fanins[0], (char **)&pFanin ) )
283  { printf( "ABC_AddGate: The fanin gate \"%s\" is not in the network.\n", fanins[0] ); return 0; }
284  Abc_ObjAddFanin( pObj, pFanin );
285  break;
286  default:
287  printf( "ABC_AddGate: Unknown gate type.\n" );
288  break;
289  }
290 
291  // map the name into the node
292  if ( stmm_insert( mng->tName2Node, name, (char *)pObj ) )
293  { printf( "ABC_AddGate: The same gate \"%s\" is added twice.\n", name ); return 0; }
294  return 1;
295 }
stmm_table * tNode2Name
Definition: csat_apis.c:40
int stmm_insert(stmm_table *table, char *key, char *value)
Definition: stmm.c:200
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:162
ABC_DLL char * Abc_SopCreateInv(Mem_Flex_t *pMan)
Definition: abcSop.c:345
ABC_DLL char * Abc_SopCreateNand(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:184
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition: mem.c:372
static void Abc_ObjSetData(Abc_Obj_t *pObj, void *pData)
Definition: abc.h:343
ABC_DLL char * Abc_SopCreateConst1(Mem_Flex_t *pMan)
Definition: abcSop.c:107
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL char * Abc_SopCreateBuf(Mem_Flex_t *pMan)
Definition: abcSop.c:361
Mem_Flex_t * pMmNames
Definition: csat_apis.c:44
stmm_table * tName2Node
Definition: csat_apis.c:39
void * pManFunc
Definition: abc.h:191
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition: stmm.c:134
ABC_DLL char * Abc_SopCreateNxor(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:311
char * name
ABC_DLL char * Abc_SopCreateXor(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:274
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
char * strcpy()
ABC_DLL char * Abc_SopCreateNor(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:253
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
int strlen()
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:206
int ABC_AddTarget ( ABC_Manager  mng,
int  nog,
char **  names,
int *  values 
)

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

Synopsis [Adds a new target to the manager.]

Description [The meaning of the parameters are: nog: number of gates that are in the targets, names: name array of gates, values: value array of the corresponding gates given in "names" to be solved. The relation of them is AND.]

SideEffects []

SeeAlso []

Definition at line 534 of file csat_apis.c.

535 {
536  Abc_Obj_t * pObj;
537  int i;
538  if ( nog < 1 )
539  { printf( "ABC_AddTarget: The target has no gates.\n" ); return 0; }
540  // clear storage for the target
541  mng->nog = 0;
542  Vec_PtrClear( mng->vNodes );
543  Vec_IntClear( mng->vValues );
544  // save the target
545  for ( i = 0; i < nog; i++ )
546  {
547  if ( !stmm_lookup( mng->tName2Node, names[i], (char **)&pObj ) )
548  { printf( "ABC_AddTarget: The target gate \"%s\" is not in the network.\n", names[i] ); return 0; }
549  Vec_PtrPush( mng->vNodes, pObj );
550  if ( values[i] < 0 || values[i] > 1 )
551  { printf( "ABC_AddTarget: The value of gate \"%s\" is not 0 or 1.\n", names[i] ); return 0; }
552  Vec_IntPush( mng->vValues, values[i] );
553  }
554  mng->nog = nog;
555  return 1;
556 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Vec_Ptr_t * vNodes
Definition: csat_apis.c:50
stmm_table * tName2Node
Definition: csat_apis.c:39
Vec_Int_t * vValues
Definition: csat_apis.c:51
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition: stmm.c:134
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void ABC_AnalyzeTargets ( ABC_Manager  mng)

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

Synopsis [Currently not implemented.]

Description []

SideEffects []

SeeAlso []

Definition at line 596 of file csat_apis.c.

597 {
598 }
int ABC_Check_Integrity ( ABC_Manager  mng)

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

Synopsis [Checks integraty of the manager.]

Description [Checks if there are gates that are not used by any primary output. If no such gates exist, return 1 else return 0.]

SideEffects []

SeeAlso []

Definition at line 332 of file csat_apis.c.

333 {
334  Abc_Ntk_t * pNtk = mng->pNtk;
335  Abc_Obj_t * pObj;
336  int i;
337 
338  // check that there are no dangling nodes
339  Abc_NtkForEachNode( pNtk, pObj, i )
340  {
341  if ( i == 0 )
342  continue;
343  if ( Abc_ObjFanoutNum(pObj) == 0 )
344  {
345 // printf( "ABC_Check_Integrity: The network has dangling nodes.\n" );
346  return 0;
347  }
348  }
349 
350  // make sure everything is okay with the network structure
351  if ( !Abc_NtkDoCheck( pNtk ) )
352  {
353  printf( "ABC_Check_Integrity: The internal network check has failed.\n" );
354  return 0;
355  }
356  return 1;
357 }
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
ABC_DLL int Abc_NtkDoCheck(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:93
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
void ABC_Dump_Bench_File ( ABC_Manager  mng)

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

Synopsis [Dumps the original network into the BENCH file.]

Description [This procedure should be modified to dump the target.]

SideEffects []

SeeAlso []

Definition at line 680 of file csat_apis.c.

681 {
682  Abc_Ntk_t * pNtkTemp, * pNtkAig;
683  const char * pFileName;
684 
685  // derive the netlist
686  pNtkAig = Abc_NtkStrash( mng->pNtk, 0, 0, 0 );
687  pNtkTemp = Abc_NtkToNetlistBench( pNtkAig );
688  Abc_NtkDelete( pNtkAig );
689  if ( pNtkTemp == NULL )
690  { printf( "ABC_Dump_Bench_File: Dumping BENCH has failed.\n" ); return; }
691  pFileName = mng->pDumpFileName? mng->pDumpFileName: "abc_test.bench";
692  Io_WriteBench( pNtkTemp, pFileName );
693  Abc_NtkDelete( pNtkTemp );
694 }
int Io_WriteBench(Abc_Ntk_t *pNtk, const char *FileName)
FUNCTION DEFINITIONS ///.
Definition: ioWriteBench.c:53
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlistBench(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:122
char * pDumpFileName
Definition: csat_apis.c:43
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
void ABC_EnableDump ( ABC_Manager  mng,
char *  dump_file 
)

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

Synopsis [Sets the file name to dump the structurally hashed network used for solving.]

Description []

SideEffects []

SeeAlso []

Definition at line 513 of file csat_apis.c.

514 {
515  ABC_FREE( mng->pDumpFileName );
516  mng->pDumpFileName = Extra_UtilStrsav( dump_file );
517 }
char * pDumpFileName
Definition: csat_apis.c:43
char * Extra_UtilStrsav(const char *s)
#define ABC_FREE(obj)
Definition: abc_global.h:232
CSAT_Target_ResultT* ABC_Get_Target_Result ( ABC_Manager  mng,
int  TargetID 
)

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

Synopsis [Gets the solve status of a target.]

Description [TargetID: the target id returned by ABC_AddTarget().]

SideEffects []

SeeAlso []

Definition at line 664 of file csat_apis.c.

665 {
666  return mng->pResult;
667 }
CSAT_Target_ResultT * pResult
Definition: csat_apis.c:53
char * ABC_GetNodeName ( ABC_Manager  mng,
Abc_Obj_t pNode 
)
static

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

Synopsis [Dumps the target AIG into the BENCH file.]

Description []

SideEffects []

SeeAlso []

Definition at line 761 of file csat_apis.c.

762 {
763  char * pName = NULL;
764  if ( !stmm_lookup( mng->tNode2Name, (char *)pNode, (char **)&pName ) )
765  {
766  assert( 0 );
767  }
768  return pName;
769 }
stmm_table * tNode2Name
Definition: csat_apis.c:40
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition: stmm.c:134
#define assert(ex)
Definition: util_old.h:213
ABC_UINT64_T ABC_GetTotalBacktracksMade ( ABC_Manager  mng)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 481 of file csat_apis.c.

482 {
483  return mng->Params.nTotalBacktracksMade;
484 }
Prove_Params_t Params
Definition: csat_apis.c:47
ABC_INT64_T nTotalBacktracksMade
Definition: ivyFraig.c:136
ABC_UINT64_T ABC_GetTotalInspectsMade ( ABC_Manager  mng)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 497 of file csat_apis.c.

498 {
499  return mng->Params.nTotalInspectsMade;
500 }
Prove_Params_t Params
Definition: csat_apis.c:47
ABC_INT64_T nTotalInspectsMade
Definition: ivyFraig.c:137
ABC_Manager ABC_InitManager ( void  )

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates a new manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file csat_apis.c.

82 {
83  ABC_Manager_t * mng;
84  Abc_Start();
85  mng = ABC_ALLOC( ABC_Manager_t, 1 );
86  memset( mng, 0, sizeof(ABC_Manager_t) );
87  mng->pNtk = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
88  mng->pNtk->pName = Extra_UtilStrsav("csat_network");
89  mng->tName2Node = stmm_init_table(strcmp, stmm_strhash);
90  mng->tNode2Name = stmm_init_table(stmm_ptrcmp, stmm_ptrhash);
91  mng->pMmNames = Mem_FlexStart();
92  mng->vNodes = Vec_PtrAlloc( 100 );
93  mng->vValues = Vec_IntAlloc( 100 );
94  mng->mode = 0; // set "resource-aware integration" as the default mode
95  // set default parameters for CEC
96  Prove_ParamsSetDefault( &mng->Params );
97  // set infinite resource limit for the final mitering
98 // mng->Params.nMiteringLimitLast = ABC_INFINITY;
99  return mng;
100 }
char * memset()
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition: stmm.c:69
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Prove_ParamsSetDefault(Prove_Params_t *pParams)
FUNCTION DEFINITIONS ///.
Definition: fraigMan.c:46
char * Extra_UtilStrsav(const char *s)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
int strcmp()
Mem_Flex_t * Mem_FlexStart()
Definition: mem.c:311
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int stmm_ptrhash(const char *x, int size)
Definition: stmm.c:533
typedefABC_NAMESPACE_HEADER_START struct ABC_ManagerStruct_t ABC_Manager_t
INCLUDES ///.
Definition: csat_apis.h:41
int stmm_strhash(const char *string, int modulus)
Definition: stmm.c:514
int stmm_ptrcmp(const char *x, const char *y)
Definition: stmm.c:545
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Abc_Start()
DECLARATIONS ///.
Definition: mainLib.c:52
void ABC_Network_Finalize ( ABC_Manager  mng)

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

Synopsis [This procedure also finalizes construction of the ABC network.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file csat_apis.c.

309 {
310  Abc_Ntk_t * pNtk = mng->pNtk;
311  Abc_Obj_t * pObj;
312  int i;
313  Abc_NtkForEachPi( pNtk, pObj, i )
314  Abc_ObjAssignName( pObj, ABC_GetNodeName(mng, pObj), NULL );
315  Abc_NtkForEachPo( pNtk, pObj, i )
316  Abc_ObjAssignName( pObj, ABC_GetNodeName(mng, pObj), NULL );
317  assert( Abc_NtkLatchNum(pNtk) == 0 );
318 }
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static char * ABC_GetNodeName(ABC_Manager mng, Abc_Obj_t *pNode)
Definition: csat_apis.c:761
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void ABC_ReleaseManager ( ABC_Manager  mng)

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

Synopsis [Deletes the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file csat_apis.c.

114 {
115  CSAT_Target_ResultT * p_res = ABC_Get_Target_Result( mng,0 );
116  ABC_TargetResFree(p_res);
117  if ( mng->tNode2Name ) stmm_free_table( mng->tNode2Name );
118  if ( mng->tName2Node ) stmm_free_table( mng->tName2Node );
119  if ( mng->pMmNames ) Mem_FlexStop( mng->pMmNames, 0 );
120  if ( mng->pNtk ) Abc_NtkDelete( mng->pNtk );
121  if ( mng->pTarget ) Abc_NtkDelete( mng->pTarget );
122  if ( mng->vNodes ) Vec_PtrFree( mng->vNodes );
123  if ( mng->vValues ) Vec_IntFree( mng->vValues );
124  ABC_FREE( mng->pDumpFileName );
125  ABC_FREE( mng );
126  Abc_Stop();
127 }
void Abc_Stop()
Definition: mainLib.c:76
CSAT_Target_ResultT * ABC_Get_Target_Result(ABC_Manager mng, int TargetID)
Definition: csat_apis.c:664
stmm_table * tNode2Name
Definition: csat_apis.c:40
void ABC_TargetResFree(CSAT_Target_ResultT *p)
Definition: csat_apis.c:733
char * pDumpFileName
Definition: csat_apis.c:43
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Mem_Flex_t * pMmNames
Definition: csat_apis.c:44
Vec_Ptr_t * vNodes
Definition: csat_apis.c:50
stmm_table * tName2Node
Definition: csat_apis.c:39
Vec_Int_t * vValues
Definition: csat_apis.c:51
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
Abc_Ntk_t * pTarget
Definition: csat_apis.c:42
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition: mem.c:343
void stmm_free_table(stmm_table *table)
Definition: stmm.c:79
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void ABC_SetLearnBacktrackLimit ( ABC_Manager  mng,
int  num 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file csat_apis.c.

403 {
404 // printf( "ABC_SetLearnBacktrackLimit: The resource limit is not implemented (warning).\n" );
405 }
void ABC_SetLearnLimit ( ABC_Manager  mng,
int  num 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 386 of file csat_apis.c.

387 {
388 // printf( "ABC_SetLearnLimit: The resource limit is not implemented (warning).\n" );
389 }
void ABC_SetSolveBacktrackLimit ( ABC_Manager  mng,
int  num 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 418 of file csat_apis.c.

419 {
420  mng->Params.nMiteringLimitLast = num;
421 }
Prove_Params_t Params
Definition: csat_apis.c:47
void ABC_SetSolveImplicationLimit ( ABC_Manager  mng,
int  num 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 434 of file csat_apis.c.

435 {
436 // printf( "ABC_SetSolveImplicationLimit: The resource limit is not implemented (warning).\n" );
437 }
void ABC_SetSolveOption ( ABC_Manager  mng,
enum CSAT_OptionT  option 
)

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

Synopsis [Sets solver options for learning.]

Description []

SideEffects []

SeeAlso []

Definition at line 140 of file csat_apis.c.

141 {
142 }
void ABC_SetTimeLimit ( ABC_Manager  mng,
int  runtime 
)

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

Synopsis [Sets time limit for solving a target.]

Description [Runtime: time limit (in second).]

SideEffects []

SeeAlso []

Definition at line 370 of file csat_apis.c.

371 {
372 // printf( "ABC_SetTimeLimit: The resource limit is not implemented (warning).\n" );
373 }
void ABC_SetTotalBacktrackLimit ( ABC_Manager  mng,
ABC_UINT64_T  num 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 450 of file csat_apis.c.

451 {
452  mng->Params.nTotalBacktrackLimit = num;
453 }
Prove_Params_t Params
Definition: csat_apis.c:47
ABC_INT64_T nTotalBacktrackLimit
Definition: ivyFraig.c:133
void ABC_SetTotalInspectLimit ( ABC_Manager  mng,
ABC_UINT64_T  num 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 466 of file csat_apis.c.

467 {
468  mng->Params.nTotalInspectLimit = num;
469 }
Prove_Params_t Params
Definition: csat_apis.c:47
ABC_INT64_T nTotalInspectLimit
Definition: ivyFraig.c:134
enum CSAT_StatusT ABC_Solve ( ABC_Manager  mng)

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

Synopsis [Solves the targets added by ABC_AddTarget().]

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file csat_apis.c.

612 {
613  Prove_Params_t * pParams = &mng->Params;
614  int RetValue, i;
615 
616  // check if the target network is available
617  if ( mng->pTarget == NULL )
618  { printf( "ABC_Solve: Target network is not derived by ABC_SolveInit().\n" ); return UNDETERMINED; }
619 
620  // try to prove the miter using a number of techniques
621  if ( mng->mode )
622  RetValue = Abc_NtkMiterSat( mng->pTarget, (ABC_INT64_T)pParams->nMiteringLimitLast, (ABC_INT64_T)0, 0, NULL, NULL );
623  else
624 // RetValue = Abc_NtkMiterProve( &mng->pTarget, pParams ); // old CEC engine
625  RetValue = Abc_NtkIvyProve( &mng->pTarget, pParams ); // new CEC engine
626 
627  // analyze the result
629  if ( RetValue == -1 )
630  mng->pResult->status = UNDETERMINED;
631  else if ( RetValue == 1 )
632  mng->pResult->status = UNSATISFIABLE;
633  else if ( RetValue == 0 )
634  {
635  mng->pResult->status = SATISFIABLE;
636  // create the array of PI names and values
637  for ( i = 0; i < mng->pResult->no_sig; i++ )
638  {
639  mng->pResult->names[i] = Extra_UtilStrsav( ABC_GetNodeName(mng, Abc_NtkCi(mng->pNtk, i)) );
640  mng->pResult->values[i] = mng->pTarget->pModel[i];
641  }
642  ABC_FREE( mng->pTarget->pModel );
643  }
644  else assert( 0 );
645 
646  // delete the target
647  Abc_NtkDelete( mng->pTarget );
648  mng->pTarget = NULL;
649  // return the status
650  return mng->pResult->status;
651 }
Prove_Params_t Params
Definition: csat_apis.c:47
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
static char * ABC_GetNodeName(ABC_Manager mng, Abc_Obj_t *pNode)
Definition: csat_apis.c:761
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
int * pModel
Definition: abc.h:198
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
Abc_Ntk_t * pTarget
Definition: csat_apis.c:42
ABC_DLL int Abc_NtkIvyProve(Abc_Ntk_t **ppNtk, void *pPars)
Definition: abcIvy.c:498
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
enum CSAT_StatusT status
Definition: csat_apis.h:123
static CSAT_Target_ResultT * ABC_TargetResAlloc(int nVars)
Definition: csat_apis.c:709
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
CSAT_Target_ResultT * pResult
Definition: csat_apis.c:53
void ABC_SolveInit ( ABC_Manager  mng)

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

Synopsis [Initialize the solver internal data structure.]

Description [Prepares the solver to work on one specific target set by calling ABC_AddTarget before.]

SideEffects []

SeeAlso []

Definition at line 570 of file csat_apis.c.

571 {
572  // check if the target is available
573  assert( mng->nog == Vec_PtrSize(mng->vNodes) );
574  if ( mng->nog == 0 )
575  { printf( "ABC_SolveInit: Target is not specified by ABC_AddTarget().\n" ); return; }
576 
577  // free the previous target network if present
578  if ( mng->pTarget ) Abc_NtkDelete( mng->pTarget );
579 
580  // set the new target network
581 // mng->pTarget = Abc_NtkCreateTarget( mng->pNtk, mng->vNodes, mng->vValues );
582  mng->pTarget = Abc_NtkStrash( mng->pNtk, 0, 1, 0 );
583 }
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Vec_Ptr_t * vNodes
Definition: csat_apis.c:50
Abc_Ntk_t * pNtk
Definition: csat_apis.c:41
Abc_Ntk_t * pTarget
Definition: csat_apis.c:42
#define assert(ex)
Definition: util_old.h:213
void Abc_Start ( )

DECLARATIONS ///.

PARAMETERS ///.

INCLUDES ///.

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

FileName [main.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [The main package.]

Synopsis [Here everything starts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Initialization procedure for the library project.]

Description [Note that when Abc_Start() is run in a static library project, it does not load the resource file by default. As a result, ABC is not set up the same way, as when it is run on a command line. For example, some error messages while parsing files will not be produced, and intermediate networks will not be checked for consistancy. One possibility is to load the resource file after Abc_Start() as follows: Abc_UtilsSource( Abc_FrameGetGlobalFrame() );]

SideEffects []

SeeAlso []

Definition at line 52 of file mainLib.c.

53 {
54  Abc_Frame_t * pAbc;
55  // added to detect memory leaks:
56 #if defined(_DEBUG) && defined(_MSC_VER)
57  _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
58 #endif
59  // start the glocal frame
60  pAbc = Abc_FrameGetGlobalFrame();
61  // source the resource file
62 // Abc_UtilsSource( pAbc );
63 }
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
void Abc_Stop ( )

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

Synopsis [Deallocation procedure for the library project.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file mainLib.c.

77 {
78  Abc_Frame_t * pAbc;
79  pAbc = Abc_FrameGetGlobalFrame();
80  // perform uninitializations
81  Abc_FrameEnd( pAbc );
82  // stop the framework
83  Abc_FrameDeallocate( pAbc );
84 }
void Abc_FrameDeallocate(Abc_Frame_t *p)
Definition: mainFrame.c:179
void Abc_FrameEnd(Abc_Frame_t *pAbc)
Definition: mainInit.c:128
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
CSAT_Target_ResultT * ABC_TargetResAlloc ( int  nVars)
static

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

Synopsis [Allocates the target result.]

Description []

SideEffects []

SeeAlso []

Definition at line 709 of file csat_apis.c.

710 {
712  p = ABC_ALLOC( CSAT_Target_ResultT, 1 );
713  memset( p, 0, sizeof(CSAT_Target_ResultT) );
714  p->no_sig = nVars;
715  p->names = ABC_ALLOC( char *, nVars );
716  p->values = ABC_ALLOC( int, nVars );
717  memset( p->names, 0, sizeof(char *) * nVars );
718  memset( p->values, 0, sizeof(int) * nVars );
719  return p;
720 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void ABC_TargetResFree ( CSAT_Target_ResultT p)

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

Synopsis [Deallocates the target result.]

Description []

SideEffects []

SeeAlso []

Definition at line 733 of file csat_apis.c.

734 {
735  if ( p == NULL )
736  return;
737  if( p->names )
738  {
739  int i = 0;
740  for ( i = 0; i < p->no_sig; i++ )
741  {
742  ABC_FREE(p->names[i]);
743  }
744  }
745  ABC_FREE( p->names );
746  ABC_FREE( p->values );
747  ABC_FREE( p );
748 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
void ABC_UseOnlyCoreSatSolver ( ABC_Manager  mng)

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

Synopsis [Sets solving mode by brute-force SAT.]

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file csat_apis.c.

156 {
157  mng->mode = 1; // switch to "brute-force SAT" as the solving option
158 }
int Io_WriteBench ( Abc_Ntk_t pNtk,
const char *  pFileName 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Writes the network in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 53 of file ioWriteBench.c.

54 {
55  Abc_Ntk_t * pExdc;
56  FILE * pFile;
57  assert( Abc_NtkIsSopNetlist(pNtk) );
58  if ( !Io_WriteBenchCheckNames(pNtk) )
59  {
60  fprintf( stdout, "Io_WriteBench(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
61  return 0;
62  }
63  pFile = fopen( pFileName, "w" );
64  if ( pFile == NULL )
65  {
66  fprintf( stdout, "Io_WriteBench(): Cannot open the output file.\n" );
67  return 0;
68  }
69  fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
70  // write the network
71  Io_WriteBenchOne( pFile, pNtk );
72  // write EXDC network if it exists
73  pExdc = Abc_NtkExdc( pNtk );
74  if ( pExdc )
75  printf( "Io_WriteBench: EXDC is not written (warning).\n" );
76  // finalize the file
77  fclose( pFile );
78  return 1;
79 }
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
Definition: abc.h:272
static ABC_NAMESPACE_IMPL_START int Io_WriteBenchCheckNames(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: ioWriteBench.c:322
static int Io_WriteBenchOne(FILE *pFile, Abc_Ntk_t *pNtk)
Definition: ioWriteBench.c:92
char * Extra_TimeStamp()
static int Abc_NtkIsSopNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:260
#define assert(ex)
Definition: util_old.h:213
char * pName
Definition: abc.h:158