abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioWriteCnf.c File Reference
#include "ioAbc.h"
#include "sat/bsat/satSolver.h"

Go to the source code of this file.

Functions

int Io_WriteCnf (Abc_Ntk_t *pNtk, char *pFileName, int fAllPrimes)
 FUNCTION DEFINITIONS ///. More...
 
void Io_WriteCnfOutputPiMapping (FILE *pFile, int incrementVars)
 

Variables

static
ABC_NAMESPACE_IMPL_START
Abc_Ntk_t
s_pNtk = NULL
 DECLARATIONS ///. More...
 

Function Documentation

int Io_WriteCnf ( Abc_Ntk_t pNtk,
char *  pFileName,
int  fAllPrimes 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Write the miter cone into a CNF file for the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file ioWriteCnf.c.

49 {
50  sat_solver * pSat;
51  if ( Abc_NtkIsStrash(pNtk) )
52  printf( "Io_WriteCnf() warning: Generating CNF by applying heuristic AIG to CNF conversion.\n" );
53  else
54  printf( "Io_WriteCnf() warning: Generating CNF by convering logic nodes into CNF clauses.\n" );
55  if ( Abc_NtkPoNum(pNtk) != 1 )
56  {
57  fprintf( stdout, "Io_WriteCnf(): Currently can only process the miter (the network with one PO).\n" );
58  return 0;
59  }
60  if ( Abc_NtkLatchNum(pNtk) != 0 )
61  {
62  fprintf( stdout, "Io_WriteCnf(): Currently can only process the miter for combinational circuits.\n" );
63  return 0;
64  }
65  if ( Abc_NtkNodeNum(pNtk) == 0 )
66  {
67  fprintf( stdout, "The network has no logic nodes. No CNF file is generaled.\n" );
68  return 0;
69  }
70  // convert to logic BDD network
71  if ( Abc_NtkIsLogic(pNtk) )
72  Abc_NtkToBdd( pNtk );
73  // create solver with clauses
74  pSat = (sat_solver *)Abc_NtkMiterSatCreate( pNtk, fAllPrimes );
75  if ( pSat == NULL )
76  {
77  fprintf( stdout, "The problem is trivially UNSAT. No CNF file is generated.\n" );
78  return 1;
79  }
80  // write the clauses
81  s_pNtk = pNtk;
82  Sat_SolverWriteDimacs( pSat, pFileName, 0, 0, 1 );
83  s_pNtk = NULL;
84  // free the solver
85  sat_solver_delete( pSat );
86  return 1;
87 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
ABC_DLL void * Abc_NtkMiterSatCreate(Abc_Ntk_t *pNtk, int fAllPrimes)
Definition: abcSat.c:629
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_DLL int Abc_NtkToBdd(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1160
void Sat_SolverWriteDimacs(sat_solver *p, char *pFileName, lit *assumptionsBegin, lit *assumptionsEnd, int incrementVars)
Definition: satUtil.c:71
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * s_pNtk
DECLARATIONS ///.
Definition: ioWriteCnf.c:31
void Io_WriteCnfOutputPiMapping ( FILE *  pFile,
int  incrementVars 
)

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

Synopsis [Output the mapping of PIs into variable numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file ioWriteCnf.c.

101 {
102  extern Vec_Int_t * Abc_NtkGetCiSatVarNums( Abc_Ntk_t * pNtk );
103  Abc_Ntk_t * pNtk = s_pNtk;
104  Vec_Int_t * vCiIds;
105  Abc_Obj_t * pObj;
106  int i;
107  vCiIds = Abc_NtkGetCiSatVarNums( pNtk );
108  fprintf( pFile, "c PI variable numbers: <PI_name> <SAT_var_number>\n" );
109  Abc_NtkForEachCi( pNtk, pObj, i )
110  fprintf( pFile, "c %s %d\n", Abc_ObjName(pObj), Vec_IntEntry(vCiIds, i) + (int)(incrementVars > 0) );
111  Vec_IntFree( vCiIds );
112 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Abc_NtkGetCiSatVarNums(Abc_Ntk_t *pNtk)
Definition: abcSat.c:154
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * s_pNtk
DECLARATIONS ///.
Definition: ioWriteCnf.c:31
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235

Variable Documentation

ABC_NAMESPACE_IMPL_START Abc_Ntk_t* s_pNtk = NULL
static

DECLARATIONS ///.

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

FileName [ioWriteCnf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to output CNF of the miter cone.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file ioWriteCnf.c.