ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmcExpand.c File Reference
#include "bmc.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
#include "base/abc/abc.h"
Include dependency graph for bmcExpand.c:

Go to the source code of this file.

Macros

#define Bmc_SopForEachCube(pSop, nVars, pCube)
 DECLARATIONS ///.
 

Functions

int Abc_ObjExpandCubesTry (Vec_Str_t *vSop, sat_solver *pSat, Vec_Int_t *vVars)
 FUNCTION DEFINITIONS ///.
 
int Abc_ObjExpandCubes (Vec_Str_t *vSop, Gia_Man_t *p, int nVars)
 
void Abc_NtkExpandCubes (Abc_Ntk_t *pNtk, Gia_Man_t *pGia, int fVerbose)
 

Macro Definition Documentation

◆ Bmc_SopForEachCube

#define Bmc_SopForEachCube ( pSop,
nVars,
pCube )
Value:
for ( pCube = (pSop); *pCube; pCube += (nVars) + 3 )

DECLARATIONS ///.

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

FileName [bmcExpand.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [Expanding cubes against the offset.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 34 of file bmcExpand.c.

Function Documentation

◆ Abc_NtkExpandCubes()

void Abc_NtkExpandCubes ( Abc_Ntk_t * pNtk,
Gia_Man_t * pGia,
int fVerbose )

Definition at line 135 of file bmcExpand.c.

136{
137 Gia_Man_t * pNew;
138 Abc_Obj_t * pObj; int i;
139 Vec_Str_t * vSop = Vec_StrAlloc( 1000 );
140 assert( Abc_NtkIsSopLogic(pNtk) );
141 assert( Abc_NtkCiNum(pNtk) == Gia_ManCiNum(pGia) );
142 assert( Abc_NtkCoNum(pNtk) == Gia_ManCoNum(pGia) );
143 Abc_NtkForEachCo( pNtk, pObj, i )
144 {
145 pObj = Abc_ObjFanin0(pObj);
146 if ( !Abc_ObjIsNode(pObj) || Abc_ObjFaninNum(pObj) == 0 )
147 continue;
148 assert( Abc_ObjFaninNum(pObj) == Gia_ManCiNum(pGia) );
149
150 Vec_StrClear( vSop );
151 Vec_StrAppend( vSop, (char *)pObj->pData );
152 Vec_StrPush( vSop, '\0' );
153
154 pNew = Gia_ManDupCones( pGia, &i, 1, 0 );
155 assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(pGia) );
156 if ( Abc_ObjExpandCubes( vSop, pNew, Abc_ObjFaninNum(pObj) ) )
157 Vec_IntClear( &pObj->vFanins );
158 Gia_ManStop( pNew );
159
160 pObj->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, Vec_StrArray(vSop) );
161 }
162 Vec_StrFree( vSop );
163 Abc_NtkSortSops( pNtk );
164}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL void Abc_NtkSortSops(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
int Abc_ObjExpandCubes(Vec_Str_t *vSop, Gia_Man_t *p, int nVars)
Definition bmcExpand.c:88
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition giaDup.c:3880
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
Vec_Int_t vFanins
Definition abc.h:143
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Abc_ObjExpandCubes()

int Abc_ObjExpandCubes ( Vec_Str_t * vSop,
Gia_Man_t * p,
int nVars )

Definition at line 88 of file bmcExpand.c.

89{
90 extern int Bmc_CollapseIrredundantFull( Vec_Str_t * vSop, int nCubes, int nVars );
91
92 int fReverse = 0;
93 Vec_Int_t * vVars = Vec_IntAlloc( nVars );
94 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8, 0, 0, 0, 0 );
95 sat_solver * pSat = (sat_solver *)Cnf_DataWriteIntoSolver(pCnf, 1, 0);
96 int v, n, iLit, status, nCubesNew, iCiVarBeg = sat_solver_nvars(pSat) - nVars;
97
98 // check that on-set/off-set is sat
99 int iOutVar = 1;
100 for ( n = 0; n < 2; n++ )
101 {
102 iLit = Abc_Var2Lit( iOutVar, n ); // n=0 => F=1 n=1 => F=0
103 status = sat_solver_solve( pSat, &iLit, &iLit + 1, 0, 0, 0, 0 );
104 if ( status == l_False )
105 {
106 Vec_StrClear( vSop );
107 Vec_StrPrintStr( vSop, n ? " 1\n" : " 0\n" );
108 Vec_StrPush( vSop, '\0' );
109 return 1;
110 }
111 }
112
113 // add literals to the solver
114 iLit = Abc_Var2Lit( iOutVar, 1 );
115 status = sat_solver_addclause( pSat, &iLit, &iLit + 1 );
116 assert( status );
117
118 // collect variables
119 if ( fReverse )
120 for ( v = nVars - 1; v >= 0; v-- )
121 Vec_IntPush( vVars, iCiVarBeg + v );
122 else
123 for ( v = 0; v < nVars; v++ )
124 Vec_IntPush( vVars, iCiVarBeg + v );
125
126 nCubesNew = Abc_ObjExpandCubesTry( vSop, pSat, vVars );
127
128 sat_solver_delete( pSat );
129 Cnf_DataFree( pCnf );
130 Vec_IntFree( vVars );
131 if ( nCubesNew > 1 )
132 Bmc_CollapseIrredundantFull( vSop, nCubesNew, nVars );
133 return 0;
134}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define l_False
Definition bmcBmcS.c:36
int Bmc_CollapseIrredundantFull(Vec_Str_t *vSop, int nCubes, int nVars)
Definition bmcClp.c:275
int Abc_ObjExpandCubesTry(Vec_Str_t *vSop, sat_solver *pSat, Vec_Int_t *vVars)
FUNCTION DEFINITIONS ///.
Definition bmcExpand.c:51
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
#define sat_solver_solve
Definition cecSatG2.c:45
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
Cube * p
Definition exorList.c:222
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition cnfMan.c:579
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_ObjExpandCubesTry()

int Abc_ObjExpandCubesTry ( Vec_Str_t * vSop,
sat_solver * pSat,
Vec_Int_t * vVars )

FUNCTION DEFINITIONS ///.

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

Synopsis [Expands cubes against the offset given as an AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file bmcExpand.c.

52{
53 extern int Bmc_CollapseExpandRound( sat_solver * pSat, sat_solver * pSatOn, Vec_Int_t * vLits, Vec_Int_t * vNums, Vec_Int_t * vTemp, int nBTLimit, int fCanon, int fOnOffSetLit );
54
55 char * pCube, * pSop = Vec_StrArray(vSop);
56 int nCubes = Abc_SopGetCubeNum(pSop);
57 int nVars = Abc_SopGetVarNum(pSop);
58
59 Vec_Int_t * vLits = Vec_IntAlloc( nVars );
60 Vec_Int_t * vTemp = Vec_IntAlloc( nVars );
61
62 assert( nVars == Vec_IntSize(vVars) );
63 assert( Vec_StrSize(vSop) == nCubes * (nVars + 3) + 1 );
64 Bmc_SopForEachCube( pSop, nVars, pCube )
65 {
66 int k, Entry;
67 // collect literals and clean cube
68 Vec_IntFill( vLits, nVars, -1 );
69 for ( k = 0; k < nVars; k++ )
70 {
71 if ( pCube[k] == '-' )
72 continue;
73 Vec_IntWriteEntry( vLits, k, Abc_Var2Lit(Vec_IntEntry(vVars, k), pCube[k] == '0') );
74 pCube[k] = '-';
75 }
76 // expand cube
77 Bmc_CollapseExpandRound( pSat, NULL, vLits, NULL, vTemp, 0, 0, -1 );
78 // insert literals
79 Vec_IntForEachEntry( vLits, Entry, k )
80 if ( Entry != -1 )
81 pCube[k] = '1' - Abc_LitIsCompl(Entry);
82 }
83
84 Vec_IntFree( vLits );
85 Vec_IntFree( vTemp );
86 return nCubes;
87}
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
int Bmc_CollapseExpandRound(sat_solver *pSat, sat_solver *pSatOn, Vec_Int_t *vLits, Vec_Int_t *vNums, Vec_Int_t *vTemp, int nBTLimit, int fCanon, int fOnOffSetLit)
Definition bmcClp.c:381
#define Bmc_SopForEachCube(pSop, nVars, pCube)
DECLARATIONS ///.
Definition bmcExpand.c:34
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function: