ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sfmNtk.c File Reference
#include "sfmInt.h"
Include dependency graph for sfmNtk.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Sfm_CheckConsistency (Vec_Wec_t *vFanins, int nPis, int nPos, Vec_Str_t *vFixed)
 DECLARATIONS ///.
 
void Sfm_CreateFanout (Vec_Wec_t *vFanins, Vec_Wec_t *vFanouts)
 
void Sfm_CreateLevel (Vec_Wec_t *vFanins, Vec_Int_t *vLevels, Vec_Str_t *vEmpty)
 
void Sfm_CreateLevelR (Vec_Wec_t *vFanouts, Vec_Int_t *vLevelsR, Vec_Str_t *vEmpty)
 
Sfm_Ntk_tSfm_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)
 
void Sfm_NtkFree (Sfm_Ntk_t *p)
 
void Sfm_NtkRemoveFanin (Sfm_Ntk_t *p, int iNode, int iFanin)
 
void Sfm_NtkAddFanin (Sfm_Ntk_t *p, int iNode, int iFanin)
 
void Sfm_NtkDeleteObj_rec (Sfm_Ntk_t *p, int iNode)
 
void Sfm_NtkUpdateLevel_rec (Sfm_Ntk_t *p, int iNode)
 
void Sfm_NtkUpdateLevelR_rec (Sfm_Ntk_t *p, int iNode)
 
void Sfm_NtkUpdate (Sfm_Ntk_t *p, int iNode, int f, int iFaninNew, word uTruth, word *pTruth)
 
Vec_Int_tSfm_NodeReadFanins (Sfm_Ntk_t *p, int i)
 
wordSfm_NodeReadTruth (Sfm_Ntk_t *p, int i)
 
int Sfm_NodeReadFixed (Sfm_Ntk_t *p, int i)
 
int Sfm_NodeReadUsed (Sfm_Ntk_t *p, int i)
 

Function Documentation

◆ Sfm_CheckConsistency()

ABC_NAMESPACE_IMPL_START void Sfm_CheckConsistency ( Vec_Wec_t * vFanins,
int nPis,
int nPos,
Vec_Str_t * vFixed )

DECLARATIONS ///.

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

FileName [sfmNtk.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based optimization using internal don't-cares.]

Synopsis [Logic network.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file sfmNtk.c.

46{
47 Vec_Int_t * vArray;
48 int i, k, Fanin;
49 // check entries
50 Vec_WecForEachLevel( vFanins, vArray, i )
51 {
52 // PIs have no fanins
53 if ( i < nPis )
54 assert( Vec_IntSize(vArray) == 0 && Vec_StrEntry(vFixed, i) == (char)0 );
55 // nodes are in a topo order; POs cannot be fanins
56 Vec_IntForEachEntry( vArray, Fanin, k )
57// assert( Fanin < i && Fanin + nPos < Vec_WecSize(vFanins) );
58 assert( Fanin + nPos < Vec_WecSize(vFanins) );
59 // POs have one fanout
60 if ( i + nPos >= Vec_WecSize(vFanins) )
61 assert( Vec_IntSize(vArray) == 1 && Vec_StrEntry(vFixed, i) == (char)0 );
62 }
63}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the caller graph for this function:

◆ Sfm_CreateFanout()

void Sfm_CreateFanout ( Vec_Wec_t * vFanins,
Vec_Wec_t * vFanouts )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file sfmNtk.c.

77{
78 Vec_Int_t * vArray;
79 int i, k, Fanin;
80 // count fanouts
81 Vec_WecInit( vFanouts, Vec_WecSize(vFanins) );
82 Vec_WecForEachLevel( vFanins, vArray, i )
83 Vec_IntForEachEntry( vArray, Fanin, k )
84 Vec_WecEntry( vFanouts, Fanin )->nSize++;
85 // allocate fanins
86 Vec_WecForEachLevel( vFanouts, vArray, i )
87 {
88 k = vArray->nSize; vArray->nSize = 0;
89 Vec_IntGrow( vArray, k );
90 }
91 // add fanouts
92 Vec_WecForEachLevel( vFanins, vArray, i )
93 Vec_IntForEachEntry( vArray, Fanin, k )
94 Vec_IntPush( Vec_WecEntry( vFanouts, Fanin ), i );
95 // verify
96 Vec_WecForEachLevel( vFanouts, vArray, i )
97 assert( Vec_IntSize(vArray) == Vec_IntCap(vArray) );
98}
Here is the caller graph for this function:

◆ Sfm_CreateLevel()

void Sfm_CreateLevel ( Vec_Wec_t * vFanins,
Vec_Int_t * vLevels,
Vec_Str_t * vEmpty )

Definition at line 118 of file sfmNtk.c.

119{
120 Vec_Int_t * vArray;
121 int i;
122 assert( Vec_IntSize(vLevels) == 0 );
123 Vec_IntFill( vLevels, Vec_WecSize(vFanins), 0 );
124 Vec_WecForEachLevel( vFanins, vArray, i )
125 Vec_IntWriteEntry( vLevels, i, Sfm_ObjLevelNew(vArray, vLevels, Sfm_ObjAddsLevelArray(vEmpty, i)) );
126}
Here is the caller graph for this function:

◆ Sfm_CreateLevelR()

void Sfm_CreateLevelR ( Vec_Wec_t * vFanouts,
Vec_Int_t * vLevelsR,
Vec_Str_t * vEmpty )

Definition at line 146 of file sfmNtk.c.

147{
148 Vec_Int_t * vArray;
149 int i;
150 assert( Vec_IntSize(vLevelsR) == 0 );
151 Vec_IntFill( vLevelsR, Vec_WecSize(vFanouts), 0 );
152 Vec_WecForEachLevelReverse( vFanouts, vArray, i )
153 Vec_IntWriteEntry( vLevelsR, i, Sfm_ObjLevelNewR(vArray, vLevelsR, Sfm_ObjAddsLevelArray(vEmpty, i)) );
154}
#define Vec_WecForEachLevelReverse(vGlob, vVec, i)
Definition vecWec.h:65
Here is the caller graph for this function:

◆ Sfm_NodeReadFanins()

Vec_Int_t * Sfm_NodeReadFanins ( Sfm_Ntk_t * p,
int i )

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

Synopsis [Public APIs of this network.]

Description []

SideEffects []

SeeAlso []

Definition at line 370 of file sfmNtk.c.

371{
372 return Vec_WecEntry( &p->vFanins, i );
373}
Cube * p
Definition exorList.c:222
Here is the caller graph for this function:

◆ Sfm_NodeReadFixed()

int Sfm_NodeReadFixed ( Sfm_Ntk_t * p,
int i )

Definition at line 378 of file sfmNtk.c.

379{
380 return (int)Vec_StrEntry( p->vFixed, i );
381}
Here is the caller graph for this function:

◆ Sfm_NodeReadTruth()

word * Sfm_NodeReadTruth ( Sfm_Ntk_t * p,
int i )

Definition at line 374 of file sfmNtk.c.

375{
376 return Sfm_ObjFaninNum(p, i) <= 6 ? Vec_WrdEntryP( p->vTruths, i ) : Vec_WrdEntryP( p->vTruths2, Vec_IntEntry(p->vStarts, i) );
377}
Here is the caller graph for this function:

◆ Sfm_NodeReadUsed()

int Sfm_NodeReadUsed ( Sfm_Ntk_t * p,
int i )

Definition at line 382 of file sfmNtk.c.

383{
384 return (Sfm_ObjFaninNum(p, i) > 0) || (Sfm_ObjFanoutNum(p, i) > 0);
385}
Here is the caller graph for this function:

◆ Sfm_NtkAddFanin()

void Sfm_NtkAddFanin ( Sfm_Ntk_t * p,
int iNode,
int iFanin )

Definition at line 277 of file sfmNtk.c.

278{
279 if ( iFanin < 0 )
280 return;
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 );
287}
Here is the caller graph for this function:

◆ Sfm_NtkConstruct()

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 )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file sfmNtk.c.

168{
169 Sfm_Ntk_t * p; int i;
170 Sfm_CheckConsistency( vFanins, nPis, nPos, vFixed );
171 p = ABC_CALLOC( Sfm_Ntk_t, 1 );
172 p->nObjs = Vec_WecSize( vFanins );
173 p->nPis = nPis;
174 p->nPos = nPos;
175 p->nNodes = p->nObjs - p->nPis - p->nPos;
176 // user data
177 p->vFixed = vFixed;
178 p->vEmpty = vEmpty;
179 p->vTruths = vTruths;
180 p->vFanins = *vFanins;
181 p->vStarts = vStarts;
182 p->vTruths2 = vTruths2;
183 ABC_FREE( vFanins );
184 // attributes
185 Sfm_CreateFanout( &p->vFanins, &p->vFanouts );
186 Sfm_CreateLevel( &p->vFanins, &p->vLevels, vEmpty );
187 Sfm_CreateLevelR( &p->vFanouts, &p->vLevelsR, vEmpty );
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 );
194 p->vCnfs = Sfm_CreateCnf( p );
195 // elementary truth tables
196 for ( i = 0; i < SFM_FANIN_MAX; i++ )
197 p->pTtElems[i] = p->TtElems[i];
198 Abc_TtElemInit( p->pTtElems, SFM_FANIN_MAX );
199 return p;
200}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
Vec_Wec_t * Sfm_CreateCnf(Sfm_Ntk_t *p)
Definition sfmCnf.c:168
#define SFM_FANIN_MAX
INCLUDES ///.
Definition sfmInt.h:51
void Sfm_CreateLevelR(Vec_Wec_t *vFanouts, Vec_Int_t *vLevelsR, Vec_Str_t *vEmpty)
Definition sfmNtk.c:146
ABC_NAMESPACE_IMPL_START void Sfm_CheckConsistency(Vec_Wec_t *vFanins, int nPis, int nPos, Vec_Str_t *vFixed)
DECLARATIONS ///.
Definition sfmNtk.c:45
void Sfm_CreateLevel(Vec_Wec_t *vFanins, Vec_Int_t *vLevels, Vec_Str_t *vEmpty)
Definition sfmNtk.c:118
void Sfm_CreateFanout(Vec_Wec_t *vFanins, Vec_Wec_t *vFanouts)
Definition sfmNtk.c:76
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
Definition sfm.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_NtkDeleteObj_rec()

void Sfm_NtkDeleteObj_rec ( Sfm_Ntk_t * p,
int iNode )

Definition at line 288 of file sfmNtk.c.

289{
290 int i, iFanin;
291 if ( Sfm_ObjFanoutNum(p, iNode) > 0 || Sfm_ObjIsPi(p, iNode) || Sfm_ObjIsFixed(p, iNode) )
292 return;
293 assert( Sfm_ObjIsNode(p, iNode) );
294 Sfm_ObjForEachFanin( p, iNode, iFanin, i )
295 {
296 int RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode ); assert( RetValue );
297 Sfm_NtkDeleteObj_rec( p, iFanin );
298 }
299 Vec_IntClear( Sfm_ObjFiArray(p, iNode) );
300 Vec_WrdWriteEntry( p->vTruths, iNode, (word)0 );
301}
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition sfmInt.h:199
void Sfm_NtkDeleteObj_rec(Sfm_Ntk_t *p, int iNode)
Definition sfmNtk.c:288
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_NtkFree()

void Sfm_NtkFree ( Sfm_Ntk_t * p)

Definition at line 219 of file sfmNtk.c.

220{
221 // user data
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 );
228 // attributes
229 Vec_WecErase( &p->vFanouts );
230 ABC_FREE( p->vLevels.pArray );
231 ABC_FREE( p->vLevelsR.pArray );
232 ABC_FREE( p->vCounts.pArray );
233 ABC_FREE( p->vTravIds.pArray );
234 ABC_FREE( p->vTravIds2.pArray );
235 ABC_FREE( p->vId2Var.pArray );
236 ABC_FREE( p->vVar2Id.pArray );
237 Vec_WecFree( p->vCnfs );
238 Vec_IntFree( p->vCover );
239 // other data
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 );
252 if ( p->pSat ) sat_solver_delete( p->pSat );
253 ABC_FREE( p );
254}
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:

◆ Sfm_NtkPrepare()

void Sfm_NtkPrepare ( Sfm_Ntk_t * p)

Definition at line 201 of file sfmNtk.c.

202{
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 );
216 p->pSat = sat_solver_new();
217 sat_solver_setnvars( p->pSat, p->pPars->nWinSizeMax );
218}
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_NtkRemoveFanin()

void Sfm_NtkRemoveFanin ( Sfm_Ntk_t * p,
int iNode,
int iFanin )

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

Synopsis [Performs resubstitution for the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 267 of file sfmNtk.c.

268{
269 int RetValue;
270 assert( Sfm_ObjIsNode(p, iNode) );
271 assert( !Sfm_ObjIsPo(p, iFanin) );
272 RetValue = Vec_IntRemove( Sfm_ObjFiArray(p, iNode), iFanin );
273 assert( RetValue );
274 RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode );
275 assert( RetValue );
276}
Here is the caller graph for this function:

◆ Sfm_NtkUpdate()

void Sfm_NtkUpdate ( Sfm_Ntk_t * p,
int iNode,
int f,
int iFaninNew,
word uTruth,
word * pTruth )

Definition at line 322 of file sfmNtk.c.

323{
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 );
328 assert( Sfm_ObjFaninNum(p, iNode) <= SFM_FANIN_MAX );
329 if ( Abc_TtIsConst0(pTruth, nWords) || Abc_TtIsConst1(pTruth, nWords) )
330 {
331 Sfm_ObjForEachFanin( p, iNode, iFanin, f )
332 {
333 int RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode ); assert( RetValue );
334 Sfm_NtkDeleteObj_rec( p, iFanin );
335 }
336 Vec_IntClear( Sfm_ObjFiArray(p, iNode) );
337 }
338 else
339 {
340 // replace old fanin by new fanin
341 Sfm_NtkRemoveFanin( p, iNode, iFanin );
342 Sfm_NtkAddFanin( p, iNode, iFaninNew );
343 // recursively remove MFFC
344 Sfm_NtkDeleteObj_rec( p, iFanin );
345 }
346 // update logic level
347 Sfm_NtkUpdateLevel_rec( p, iNode );
348 if ( iFaninNew != -1 )
349 Sfm_NtkUpdateLevelR_rec( p, iFaninNew );
350 if ( Sfm_ObjFanoutNum(p, iFanin) > 0 )
351 Sfm_NtkUpdateLevelR_rec( p, iFanin );
352 // update truth table
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 );
356 Sfm_TruthToCnf( uTruth, pTruth, Sfm_ObjFaninNum(p, iNode), p->vCover, (Vec_Str_t *)Vec_WecEntry(p->vCnfs, iNode) );
357}
int nWords
Definition abcNpn.c:127
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
int Sfm_TruthToCnf(word Truth, word *pTruth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Definition sfmCnf.c:71
void Sfm_NtkAddFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
Definition sfmNtk.c:277
void Sfm_NtkRemoveFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
Definition sfmNtk.c:267
void Sfm_NtkUpdateLevel_rec(Sfm_Ntk_t *p, int iNode)
Definition sfmNtk.c:302
void Sfm_NtkUpdateLevelR_rec(Sfm_Ntk_t *p, int iNode)
Definition sfmNtk.c:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_NtkUpdateLevel_rec()

void Sfm_NtkUpdateLevel_rec ( Sfm_Ntk_t * p,
int iNode )

Definition at line 302 of file sfmNtk.c.

303{
304 int i, iFanout;
305 int LevelNew = Sfm_ObjLevelNew( Sfm_ObjFiArray(p, iNode), &p->vLevels, Sfm_ObjAddsLevel(p, iNode) );
306 if ( LevelNew == Sfm_ObjLevel(p, iNode) )
307 return;
308 Sfm_ObjSetLevel( p, iNode, LevelNew );
309 Sfm_ObjForEachFanout( p, iNode, iFanout, i )
310 Sfm_NtkUpdateLevel_rec( p, iFanout );
311}
#define Sfm_ObjForEachFanout(p, Node, Fan, i)
Definition sfmInt.h:200
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_NtkUpdateLevelR_rec()

void Sfm_NtkUpdateLevelR_rec ( Sfm_Ntk_t * p,
int iNode )

Definition at line 312 of file sfmNtk.c.

313{
314 int i, iFanin;
315 int LevelNew = Sfm_ObjLevelNewR( Sfm_ObjFoArray(p, iNode), &p->vLevelsR, Sfm_ObjAddsLevel(p, iNode) );
316 if ( LevelNew == Sfm_ObjLevelR(p, iNode) )
317 return;
318 Sfm_ObjSetLevelR( p, iNode, LevelNew );
319 Sfm_ObjForEachFanin( p, iNode, iFanin, i )
320 Sfm_NtkUpdateLevelR_rec( p, iFanin );
321}
Here is the call graph for this function:
Here is the caller graph for this function: