src/aig/cnf/cnfMan.c File Reference

#include "cnf.h"
#include "satSolver.h"
Include dependency graph for cnfMan.c:

Go to the source code of this file.

Functions

static int Cnf_Lit2Var (int Lit)
static int Cnf_Lit2Var2 (int Lit)
Cnf_Man_tCnf_ManStart ()
void Cnf_ManStop (Cnf_Man_t *p)
Vec_Int_tCnf_DataCollectPiSatNums (Cnf_Dat_t *pCnf, Aig_Man_t *p)
void Cnf_DataFree (Cnf_Dat_t *p)
void Cnf_DataWriteIntoFile (Cnf_Dat_t *p, char *pFileName, int fReadable)
void * Cnf_DataWriteIntoSolver (Cnf_Dat_t *p)

Function Documentation

Vec_Int_t* Cnf_DataCollectPiSatNums ( Cnf_Dat_t pCnf,
Aig_Man_t p 
)

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

Synopsis [Returns the array of CI IDs.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file cnfMan.c.

00100 {
00101     Vec_Int_t * vCiIds;
00102     Aig_Obj_t * pObj;
00103     int i;
00104     vCiIds = Vec_IntAlloc( Aig_ManPiNum(p) );
00105     Aig_ManForEachPi( p, pObj, i )
00106         Vec_IntPush( vCiIds, pCnf->pVarNums[pObj->Id] );
00107     return vCiIds;
00108 }

void Cnf_DataFree ( Cnf_Dat_t p  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file cnfMan.c.

00122 {
00123     if ( p == NULL )
00124         return;
00125     free( p->pClauses[0] );
00126     free( p->pClauses );
00127     free( p->pVarNums );
00128     free( p );
00129 }

void Cnf_DataWriteIntoFile ( Cnf_Dat_t p,
char *  pFileName,
int  fReadable 
)

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

Synopsis [Writes CNF into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file cnfMan.c.

00143 {
00144     FILE * pFile;
00145     int * pLit, * pStop, i;
00146     pFile = fopen( pFileName, "w" );
00147     if ( pFile == NULL )
00148     {
00149         printf( "Cnf_WriteIntoFile(): Output file cannot be opened.\n" );
00150         return;
00151     }
00152     fprintf( pFile, "c Result of efficient AIG-to-CNF conversion using package CNF\n" );
00153     fprintf( pFile, "p %d %d\n", p->nVars, p->nClauses );
00154     for ( i = 0; i < p->nClauses; i++ )
00155     {
00156         for ( pLit = p->pClauses[i], pStop = p->pClauses[i+1]; pLit < pStop; pLit++ )
00157             fprintf( pFile, "%d ", fReadable? Cnf_Lit2Var2(*pLit) : Cnf_Lit2Var(*pLit) );
00158         fprintf( pFile, "0\n" );
00159     }
00160     fprintf( pFile, "\n" );
00161     fclose( pFile );
00162 }

void* Cnf_DataWriteIntoSolver ( Cnf_Dat_t p  ) 

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

Synopsis [Writes CNF into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 175 of file cnfMan.c.

00176 {
00177     sat_solver * pSat;
00178     int i, status;
00179     pSat = sat_solver_new();
00180     sat_solver_setnvars( pSat, p->nVars );
00181     for ( i = 0; i < p->nClauses; i++ )
00182     {
00183         if ( !sat_solver_addclause( pSat, p->pClauses[i], p->pClauses[i+1] ) )
00184         {
00185             sat_solver_delete( pSat );
00186             return NULL;
00187         }
00188     }
00189     status = sat_solver_simplify(pSat);
00190     if ( status == 0 )
00191     {
00192         sat_solver_delete( pSat );
00193         return NULL;
00194     }
00195     return pSat;
00196 }

static int Cnf_Lit2Var ( int  Lit  )  [inline, static]

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

FileName [cnfMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG-to-CNF conversion.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id
cnfMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

] DECLARATIONS ///

Definition at line 28 of file cnfMan.c.

00028 { return (Lit & 1)? -(Lit >> 1)-1 : (Lit >> 1)+1;  }

static int Cnf_Lit2Var2 ( int  Lit  )  [inline, static]

Definition at line 29 of file cnfMan.c.

00029 { return (Lit & 1)? -(Lit >> 1)   : (Lit >> 1);    }

Cnf_Man_t* Cnf_ManStart (  ) 

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

Synopsis [Starts the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file cnfMan.c.

00047 {
00048     Cnf_Man_t * p;
00049     int i;
00050     // allocate the manager
00051     p = ALLOC( Cnf_Man_t, 1 );
00052     memset( p, 0, sizeof(Cnf_Man_t) );
00053     // derive internal data structures
00054     Cnf_ReadMsops( &p->pSopSizes, &p->pSops );
00055     // allocate memory manager for cuts
00056     p->pMemCuts = Aig_MmFlexStart();
00057     p->nMergeLimit = 10;
00058     // allocate temporary truth tables
00059     p->pTruths[0] = ALLOC( unsigned, 4 * Aig_TruthWordNum(p->nMergeLimit) );
00060     for ( i = 1; i < 4; i++ )
00061         p->pTruths[i] = p->pTruths[i-1] + Aig_TruthWordNum(p->nMergeLimit);
00062     p->vMemory = Vec_IntAlloc( 1 << 18 );
00063     return p;
00064 }

void Cnf_ManStop ( Cnf_Man_t p  ) 

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

Synopsis [Stops the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file cnfMan.c.

00078 {
00079     Vec_IntFree( p->vMemory );
00080     free( p->pTruths[0] );
00081     Aig_MmFlexStop( p->pMemCuts, 0 );
00082     free( p->pSopSizes );
00083     free( p->pSops[1] );
00084     free( p->pSops );
00085     free( p );
00086 }


Generated on Tue Jan 5 12:18:14 2010 for abc70930 by  doxygen 1.6.1