ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioWriteCnf.c File Reference
#include "ioAbc.h"
#include "sat/bsat/satSolver.h"
Include dependency graph for ioWriteCnf.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ Io_WriteCnf()

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}
ABC_DLL void * Abc_NtkMiterSatCreate(Abc_Ntk_t *pNtk, int fAllPrimes)
Definition abcSat.c:664
ABC_DLL int Abc_NtkToBdd(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1299
#define sat_solver
Definition cecSatG2.c:34
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
void Sat_SolverWriteDimacs(sat_solver *p, char *pFileName, lit *assumptionsBegin, lit *assumptionsEnd, int incrementVars)
Definition satUtil.c:74
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteCnfOutputPiMapping()

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}
Vec_Int_t * Abc_NtkGetCiSatVarNums(Abc_Ntk_t *pNtk)
Definition abcSat.c:189
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Here is the call graph for this function: