ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmcMaj2.c File Reference
#include "bmc.h"
#include "misc/extra/extra.h"
#include "misc/util/utilTruth.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
Include dependency graph for bmcMaj2.c:

Go to the source code of this file.

Classes

struct  Maj_Man_t_
 
struct  Exa_Man_t_
 
struct  Exa3_Man_t_
 

Macros

#define MAJ_NOBJS   32
 DECLARATIONS ///.
 

Functions

int Maj_ManExactSynthesis2 (int nVars, int nNodes, int fUseConst, int fUseLine, int fUseRand, int nRands, int fVerbose)
 
int Maj_ManExactSynthesisTest ()
 
void Exa_ManExactSynthesis2 (Bmc_EsPar_t *pPars)
 
void Exa3_ManExactSynthesis2 (Bmc_EsPar_t *pPars)
 

Macro Definition Documentation

◆ MAJ_NOBJS

#define MAJ_NOBJS   32

DECLARATIONS ///.

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

FileName [bmcMaj2.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [Exact synthesis with majority gates.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - October 1, 2017.]

Revision [

Id
bmcMaj.c,v 1.00 2017/10/01 00:00:00 alanmi Exp

]

Definition at line 33 of file bmcMaj2.c.

Function Documentation

◆ Exa3_ManExactSynthesis2()

void Exa3_ManExactSynthesis2 ( Bmc_EsPar_t * pPars)

Definition at line 1385 of file bmcMaj2.c.

1386{
1387 int i, status, iMint = 1;
1388 abctime clkTotal = Abc_Clock();
1389 Exa3_Man_t * p; int fCompl = 0;
1390 word pTruth[16];
1391 if ( pPars->pSymStr ) {
1392 word * pFun = Abc_TtSymFunGenerate( pPars->pSymStr, pPars->nVars );
1393 pPars->pTtStr = ABC_CALLOC( char, pPars->nVars > 2 ? (1 << (pPars->nVars-2)) + 1 : 2 );
1394 Extra_PrintHexadecimalString( pPars->pTtStr, (unsigned *)pFun, pPars->nVars );
1395 printf( "Generated symmetric function: %s\n", pPars->pTtStr );
1396 ABC_FREE( pFun );
1397 }
1398 if ( pPars->pTtStr )
1399 Abc_TtReadHex( pTruth, pPars->pTtStr );
1400 else assert( 0 );
1401 assert( pPars->nVars <= 10 );
1402 assert( pPars->nLutSize <= 6 );
1403 p = Exa3_ManAlloc( pPars, pTruth );
1404 if ( pTruth[0] & 1 ) { fCompl = 1; Abc_TtNot( pTruth, p->nWords ); }
1405 status = Exa3_ManAddCnfStart( p, pPars->fOnlyAnd );
1406 assert( status );
1407 printf( "Running exact synthesis for %d-input function with %d %d-input LUTs...\n", p->nVars, p->nNodes, p->nLutSize );
1408 for ( i = 0; iMint != -1; i++ )
1409 {
1410 abctime clk = Abc_Clock();
1411 if ( !Exa3_ManAddCnf( p, iMint ) )
1412 break;
1413 status = sat_solver_solve( p->pSat, NULL, NULL, 0, 0, 0, 0 );
1414 if ( pPars->fVerbose )
1415 {
1416 printf( "Iter %3d : ", i );
1417 Extra_PrintBinary( stdout, (unsigned *)&iMint, p->nVars );
1418 printf( " Var =%5d ", p->iVar );
1419 printf( "Cla =%6d ", sat_solver_nclauses(p->pSat) );
1420 printf( "Conf =%9d ", sat_solver_nconflicts(p->pSat) );
1421 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1422 }
1423 if ( status == l_False )
1424 {
1425 printf( "The problem has no solution.\n" );
1426 break;
1427 }
1428 iMint = Exa3_ManEval( p );
1429 }
1430 if ( iMint == -1 )
1431 Exa3_ManPrintSolution( p, fCompl );
1432 Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
1433 if ( iMint == -1 )
1434 Exa3_ManDumpBlif( p, fCompl );
1435 if ( pPars->pSymStr )
1436 ABC_FREE( pPars->pTtStr );
1437 Exa3_ManFree( p );
1438}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define l_False
Definition bmcBmcS.c:36
struct Exa3_Man_t_ Exa3_Man_t
Definition bmcMaj.c:994
#define sat_solver_solve
Definition cecSatG2.c:45
Cube * p
Definition exorList.c:222
void Extra_PrintHexadecimalString(char *pString, unsigned Sign[], int nVars)
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int sat_solver_nconflicts(sat_solver *s)
Definition satSolver.c:2381
int sat_solver_nclauses(sat_solver *s)
Definition satSolver.c:2375
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Exa_ManExactSynthesis2()

void Exa_ManExactSynthesis2 ( Bmc_EsPar_t * pPars)

Definition at line 852 of file bmcMaj2.c.

853{
854 int i, status, iMint = 1;
855 abctime clkTotal = Abc_Clock();
856 Exa_Man_t * p; int fCompl = 0;
857 word pTruth[16]; Abc_TtReadHex( pTruth, pPars->pTtStr );
858 assert( pPars->nVars <= 10 );
859 p = Exa_ManAlloc( pPars, pTruth );
860 if ( pTruth[0] & 1 ) { fCompl = 1; Abc_TtNot( pTruth, p->nWords ); }
861 status = Exa_ManAddCnfStart( p, pPars->fOnlyAnd );
862 assert( status );
863 printf( "Running exact synthesis for %d-input function with %d two-input gates...\n", p->nVars, p->nNodes );
864 for ( i = 0; iMint != -1; i++ )
865 {
866 abctime clk = Abc_Clock();
867 if ( !Exa_ManAddCnf( p, iMint ) )
868 break;
869 status = sat_solver_solve( p->pSat, NULL, NULL, 0, 0, 0, 0 );
870 if ( pPars->fVerbose )
871 {
872 printf( "Iter %3d : ", i );
873 Extra_PrintBinary( stdout, (unsigned *)&iMint, p->nVars );
874 printf( " Var =%5d ", p->iVar );
875 printf( "Cla =%6d ", sat_solver_nclauses(p->pSat) );
876 printf( "Conf =%9d ", sat_solver_nconflicts(p->pSat) );
877 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
878 }
879 if ( status == l_False )
880 {
881 printf( "The problem has no solution.\n" );
882 break;
883 }
884 iMint = Exa_ManEval( p );
885 }
886 if ( iMint == -1 )
887 Exa_ManPrintSolution( p, fCompl );
888 Exa_ManFree( p );
889 Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
890}
struct Exa_Man_t_ Exa_Man_t
Definition bmcMaj.c:421
Exa_Man_t * Exa_ManAlloc(Bmc_EsPar_t *pPars, word *pTruth)
Definition bmcMaj.c:502
void Exa_ManPrintSolution(Exa_Man_t *p, int fCompl)
Definition bmcMaj.c:659
int Exa_ManAddCnf(Exa_Man_t *p, int iMint)
Definition bmcMaj.c:885
void Exa_ManFree(Exa_Man_t *p)
Definition bmcMaj.c:527
int Exa_ManAddCnfStart(Exa_Man_t *p, int fOnlyAnd)
Definition bmcMaj.c:764
Here is the call graph for this function:

◆ Maj_ManExactSynthesis2()

int Maj_ManExactSynthesis2 ( int nVars,
int nNodes,
int fUseConst,
int fUseLine,
int fUseRand,
int nRands,
int fVerbose )

Definition at line 462 of file bmcMaj2.c.

463{
464 int i, iMint = 0;
465 abctime clkTotal = Abc_Clock();
466 Maj_Man_t * p = Maj_ManAlloc( nVars, nNodes, fUseConst, fUseLine, fUseRand, nRands, fVerbose );
467 int status = Maj_ManAddCnfStart( p );
468 assert( status );
469 if ( fVerbose )
470 printf( "Running exact synthesis for %d-input majority with %d MAJ3 gates...\n", p->nVars, p->nNodes );
471 for ( i = 0; iMint != -1; i++ )
472 {
473 abctime clk = Abc_Clock();
474 if ( !Maj_ManAddCnf( p, iMint ) )
475 {
476 printf( "The problem has no solution after %2d iterations. ", i+1 );
477 break;
478 }
479 status = sat_solver_solve( p->pSat, NULL, NULL, 0, 0, 0, 0 );
480 if ( fVerbose )
481 {
482 printf( "Iter %3d : ", i );
483 Extra_PrintBinary( stdout, (unsigned *)&iMint, p->nVars );
484 printf( " Var =%5d ", p->iVar );
485 printf( "Cla =%6d ", sat_solver_nclauses(p->pSat) );
486 printf( "Conf =%9d ", sat_solver_nconflicts(p->pSat) );
487 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
488 }
489 if ( status == l_False )
490 {
491 printf( "The problem has no solution after %2d iterations. ", i+1 );
492 break;
493 }
494 iMint = Maj_ManEval( p );
495 }
496 if ( iMint == -1 )
498 Maj_ManFree( p );
499 Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
500 return iMint == -1;
501}
void Maj_ManFree(Maj_Man_t *p)
Definition bmcMaj.c:164
struct Maj_Man_t_ Maj_Man_t
Definition bmcMaj.c:46
int Maj_ManAddCnf(Maj_Man_t *p, int iMint)
Definition bmcMaj.c:325
Maj_Man_t * Maj_ManAlloc(int nVars, int nNodes, int fUseConst, int fUseLine)
Definition bmcMaj.c:147
void Maj_ManPrintSolution(Maj_Man_t *p)
Definition bmcMaj.c:244
int Maj_ManAddCnfStart(Maj_Man_t *p)
Definition bmcMaj.c:278
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Maj_ManExactSynthesisTest()

int Maj_ManExactSynthesisTest ( )

Definition at line 503 of file bmcMaj2.c.

504{
505// while ( !Maj_ManExactSynthesis2( 5, 4, 0, 0, 1, 1, 0 ) );
506// while ( !Maj_ManExactSynthesis2( 7, 7, 0, 0, 1, 2, 0 ) );
507 while ( !Maj_ManExactSynthesis2( 9, 10, 0, 0, 1, 3, 0 ) );
508 return 1;
509}
int Maj_ManExactSynthesis2(int nVars, int nNodes, int fUseConst, int fUseLine, int fUseRand, int nRands, int fVerbose)
Definition bmcMaj2.c:462
Here is the call graph for this function: