54 assert( Vec_IntSize(vArray) == 0 && Vec_StrEntry(vFixed, i) == (
char)0 );
58 assert( Fanin + nPos < Vec_WecSize(vFanins) );
60 if ( i + nPos >= Vec_WecSize(vFanins) )
61 assert( Vec_IntSize(vArray) == 1 && Vec_StrEntry(vFixed, i) == (
char)0 );
81 Vec_WecInit( vFanouts, Vec_WecSize(vFanins) );
84 Vec_WecEntry( vFanouts, Fanin )->nSize++;
88 k = vArray->nSize; vArray->nSize = 0;
89 Vec_IntGrow( vArray, k );
94 Vec_IntPush( Vec_WecEntry( vFanouts, Fanin ), i );
97 assert( Vec_IntSize(vArray) == Vec_IntCap(vArray) );
111static inline int Sfm_ObjLevelNew(
Vec_Int_t * vArray,
Vec_Int_t * vLevels,
int fAddLevel )
113 int k, Fanin, Level = 0;
115 Level = Abc_MaxInt( Level, Vec_IntEntry(vLevels, Fanin) );
116 return Level + fAddLevel;
122 assert( Vec_IntSize(vLevels) == 0 );
123 Vec_IntFill( vLevels, Vec_WecSize(vFanins), 0 );
125 Vec_IntWriteEntry( vLevels, i, Sfm_ObjLevelNew(vArray, vLevels, Sfm_ObjAddsLevelArray(vEmpty, i)) );
139static inline int Sfm_ObjLevelNewR(
Vec_Int_t * vArray,
Vec_Int_t * vLevelsR,
int fAddLevel )
141 int k, Fanout, LevelR = 0;
143 LevelR = Abc_MaxInt( LevelR, Vec_IntEntry(vLevelsR, Fanout) );
144 return LevelR + fAddLevel;
150 assert( Vec_IntSize(vLevelsR) == 0 );
151 Vec_IntFill( vLevelsR, Vec_WecSize(vFanouts), 0 );
153 Vec_IntWriteEntry( vLevelsR, i, Sfm_ObjLevelNewR(vArray, vLevelsR, Sfm_ObjAddsLevelArray(vEmpty, i)) );
172 p->nObjs = Vec_WecSize( vFanins );
175 p->nNodes =
p->nObjs -
p->nPis -
p->nPos;
179 p->vTruths = vTruths;
180 p->vFanins = *vFanins;
181 p->vStarts = vStarts;
182 p->vTruths2 = vTruths2;
188 Vec_IntFill( &
p->vCounts,
p->nObjs, 0 );
189 Vec_IntFill( &
p->vTravIds,
p->nObjs, 0 );
190 Vec_IntFill( &
p->vTravIds2,
p->nObjs, 0 );
191 Vec_IntFill( &
p->vId2Var, 2*
p->nObjs, -1 );
192 Vec_IntFill( &
p->vVar2Id, 2*
p->nObjs, -1 );
193 p->vCover = Vec_IntAlloc( 1 << 16 );
197 p->pTtElems[i] =
p->TtElems[i];
203 p->nLevelMax = Vec_IntFindMax(&
p->vLevels) +
p->pPars->nGrowthLevel;
204 p->vNodes = Vec_IntAlloc( 1000 );
205 p->vDivs = Vec_IntAlloc( 100 );
206 p->vRoots = Vec_IntAlloc( 1000 );
207 p->vTfo = Vec_IntAlloc( 1000 );
208 p->vDivCexes = Vec_WrdStart(
p->pPars->nWinSizeMax );
209 p->vOrder = Vec_IntAlloc( 100 );
210 p->vDivVars = Vec_IntAlloc( 100 );
211 p->vDivIds = Vec_IntAlloc( 1000 );
212 p->vLits = Vec_IntAlloc( 100 );
213 p->vValues = Vec_IntAlloc( 100 );
214 p->vClauses = Vec_WecAlloc( 100 );
215 p->vFaninMap = Vec_IntAlloc( 10 );
222 Vec_StrFree(
p->vFixed );
223 Vec_StrFreeP( &
p->vEmpty );
224 Vec_WrdFree(
p->vTruths );
225 Vec_WecErase( &
p->vFanins );
226 Vec_IntFree(
p->vStarts );
227 Vec_WrdFree(
p->vTruths2 );
229 Vec_WecErase( &
p->vFanouts );
237 Vec_WecFree(
p->vCnfs );
238 Vec_IntFree(
p->vCover );
240 Vec_IntFreeP( &
p->vNodes );
241 Vec_IntFreeP( &
p->vDivs );
242 Vec_IntFreeP( &
p->vRoots );
243 Vec_IntFreeP( &
p->vTfo );
244 Vec_WrdFreeP( &
p->vDivCexes );
245 Vec_IntFreeP( &
p->vOrder );
246 Vec_IntFreeP( &
p->vDivVars );
247 Vec_IntFreeP( &
p->vDivIds );
248 Vec_IntFreeP( &
p->vLits );
249 Vec_IntFreeP( &
p->vValues );
250 Vec_WecFreeP( &
p->vClauses );
251 Vec_IntFreeP( &
p->vFaninMap );
270 assert( Sfm_ObjIsNode(
p, iNode) );
271 assert( !Sfm_ObjIsPo(
p, iFanin) );
272 RetValue = Vec_IntRemove( Sfm_ObjFiArray(
p, iNode), iFanin );
274 RetValue = Vec_IntRemove( Sfm_ObjFoArray(
p, iFanin), iNode );
281 assert( Sfm_ObjIsNode(
p, iNode) );
282 assert( !Sfm_ObjIsPo(
p, iFanin) );
283 assert( Vec_IntFind( Sfm_ObjFiArray(
p, iNode), iFanin ) == -1 );
284 assert( Vec_IntFind( Sfm_ObjFoArray(
p, iFanin), iNode ) == -1 );
285 Vec_IntPush( Sfm_ObjFiArray(
p, iNode), iFanin );
286 Vec_IntPush( Sfm_ObjFoArray(
p, iFanin), iNode );
291 if ( Sfm_ObjFanoutNum(
p, iNode) > 0 || Sfm_ObjIsPi(
p, iNode) || Sfm_ObjIsFixed(
p, iNode) )
293 assert( Sfm_ObjIsNode(
p, iNode) );
296 int RetValue = Vec_IntRemove( Sfm_ObjFoArray(
p, iFanin), iNode );
assert( RetValue );
299 Vec_IntClear( Sfm_ObjFiArray(
p, iNode) );
300 Vec_WrdWriteEntry(
p->vTruths, iNode, (
word)0 );
305 int LevelNew = Sfm_ObjLevelNew( Sfm_ObjFiArray(
p, iNode), &
p->vLevels, Sfm_ObjAddsLevel(
p, iNode) );
306 if ( LevelNew == Sfm_ObjLevel(
p, iNode) )
308 Sfm_ObjSetLevel(
p, iNode, LevelNew );
315 int LevelNew = Sfm_ObjLevelNewR( Sfm_ObjFoArray(
p, iNode), &
p->vLevelsR, Sfm_ObjAddsLevel(
p, iNode) );
316 if ( LevelNew == Sfm_ObjLevelR(
p, iNode) )
318 Sfm_ObjSetLevelR(
p, iNode, LevelNew );
324 int iFanin = Sfm_ObjFanin(
p, iNode, f );
325 int nWords = Abc_Truth6WordNum( Sfm_ObjFaninNum(
p, iNode) - (
int)(iFaninNew == -1) );
326 assert( Sfm_ObjIsNode(
p, iNode) );
327 assert( iFanin != iFaninNew );
329 if ( Abc_TtIsConst0(pTruth,
nWords) || Abc_TtIsConst1(pTruth,
nWords) )
333 int RetValue = Vec_IntRemove( Sfm_ObjFoArray(
p, iFanin), iNode );
assert( RetValue );
336 Vec_IntClear( Sfm_ObjFiArray(
p, iNode) );
348 if ( iFaninNew != -1 )
350 if ( Sfm_ObjFanoutNum(
p, iFanin) > 0 )
353 Vec_WrdWriteEntry(
p->vTruths, iNode, uTruth );
354 if (
p->vTruths2 && Vec_WrdSize(
p->vTruths2) )
355 Abc_TtCopy( Vec_WrdEntryP(
p->vTruths2, Vec_IntEntry(
p->vStarts, iNode)), pTruth,
nWords, 0 );
372 return Vec_WecEntry( &
p->vFanins, i );
376 return Sfm_ObjFaninNum(
p, i) <= 6 ? Vec_WrdEntryP(
p->vTruths, i ) : Vec_WrdEntryP(
p->vTruths2, Vec_IntEntry(
p->vStarts, i) );
380 return (
int)Vec_StrEntry(
p->vFixed, i );
384 return (Sfm_ObjFaninNum(
p, i) > 0) || (Sfm_ObjFanoutNum(
p, i) > 0);
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
unsigned __int64 word
DECLARATIONS ///.
sat_solver * sat_solver_new(void)
void sat_solver_setnvars(sat_solver *s, int n)
void sat_solver_delete(sat_solver *s)
int Sfm_TruthToCnf(word Truth, word *pTruth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Vec_Wec_t * Sfm_CreateCnf(Sfm_Ntk_t *p)
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
#define Sfm_ObjForEachFanout(p, Node, Fan, i)
#define SFM_FANIN_MAX
INCLUDES ///.
void Sfm_CreateLevelR(Vec_Wec_t *vFanouts, Vec_Int_t *vLevelsR, Vec_Str_t *vEmpty)
void Sfm_NtkUpdate(Sfm_Ntk_t *p, int iNode, int f, int iFaninNew, word uTruth, word *pTruth)
void Sfm_NtkAddFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
void Sfm_NtkFree(Sfm_Ntk_t *p)
void Sfm_NtkDeleteObj_rec(Sfm_Ntk_t *p, int iNode)
int Sfm_NodeReadFixed(Sfm_Ntk_t *p, int i)
Sfm_Ntk_t * Sfm_NtkConstruct(Vec_Wec_t *vFanins, int nPis, int nPos, Vec_Str_t *vFixed, Vec_Str_t *vEmpty, Vec_Wrd_t *vTruths, Vec_Int_t *vStarts, Vec_Wrd_t *vTruths2)
void Sfm_NtkPrepare(Sfm_Ntk_t *p)
int Sfm_NodeReadUsed(Sfm_Ntk_t *p, int i)
ABC_NAMESPACE_IMPL_START void Sfm_CheckConsistency(Vec_Wec_t *vFanins, int nPis, int nPos, Vec_Str_t *vFixed)
DECLARATIONS ///.
void Sfm_CreateLevel(Vec_Wec_t *vFanins, Vec_Int_t *vLevels, Vec_Str_t *vEmpty)
void Sfm_NtkRemoveFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
word * Sfm_NodeReadTruth(Sfm_Ntk_t *p, int i)
void Sfm_CreateFanout(Vec_Wec_t *vFanins, Vec_Wec_t *vFanouts)
void Sfm_NtkUpdateLevel_rec(Sfm_Ntk_t *p, int iNode)
Vec_Int_t * Sfm_NodeReadFanins(Sfm_Ntk_t *p, int i)
void Sfm_NtkUpdateLevelR_rec(Sfm_Ntk_t *p, int iNode)
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevelReverse(vGlob, vVec, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.