abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sfmNtk.c File Reference
#include "sfmInt.h"

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 ///. More...
 
void Sfm_CreateFanout (Vec_Wec_t *vFanins, Vec_Wec_t *vFanouts)
 
static int Sfm_ObjLevelNew (Vec_Int_t *vArray, Vec_Int_t *vLevels, int fAddLevel)
 
void Sfm_CreateLevel (Vec_Wec_t *vFanins, Vec_Int_t *vLevels, Vec_Str_t *vEmpty)
 
static int Sfm_ObjLevelNewR (Vec_Int_t *vArray, Vec_Int_t *vLevelsR, int fAddLevel)
 
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)
 
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)
 
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

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
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition: vecWec.h:55
if(last==0)
Definition: sparse_int.h:34
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
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 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition: vecWec.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntCap(Vec_Int_t *p)
Definition: vecInt.h:368
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void Vec_WecInit(Vec_Wec_t *p, int nSize)
Definition: vecWec.h:125
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 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition: vecWec.h:55
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Sfm_ObjLevelNew(Vec_Int_t *vArray, Vec_Int_t *vLevels, int fAddLevel)
Definition: sfmNtk.c:111
static int Sfm_ObjAddsLevelArray(Vec_Str_t *p, int i)
Definition: sfmInt.h:133
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
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 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Sfm_ObjLevelNewR(Vec_Int_t *vArray, Vec_Int_t *vLevelsR, int fAddLevel)
Definition: sfmNtk.c:139
static int Sfm_ObjAddsLevelArray(Vec_Str_t *p, int i)
Definition: sfmInt.h:133
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Vec_WecForEachLevelReverse(vGlob, vVec, i)
Definition: vecWec.h:65
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t* Sfm_NodeReadFanins ( Sfm_Ntk_t p,
int  i 
)

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

Synopsis [Public APIs of this network.]

Description []

SideEffects []

SeeAlso []

Definition at line 358 of file sfmNtk.c.

359 {
360  return Vec_WecEntry( &p->vFanins, i );
361 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
int Sfm_NodeReadFixed ( Sfm_Ntk_t p,
int  i 
)

Definition at line 366 of file sfmNtk.c.

367 {
368  return (int)Vec_StrEntry( p->vFixed, i );
369 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
word* Sfm_NodeReadTruth ( Sfm_Ntk_t p,
int  i 
)

Definition at line 362 of file sfmNtk.c.

363 {
364  return Vec_WrdEntryP( p->vTruths, i );
365 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:401
int Sfm_NodeReadUsed ( Sfm_Ntk_t p,
int  i 
)

Definition at line 370 of file sfmNtk.c.

371 {
372  return (Sfm_ObjFaninNum(p, i) > 0) || (Sfm_ObjFanoutNum(p, i) > 0);
373 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjFaninNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:139
static int Sfm_ObjFanoutNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:140
void Sfm_NtkAddFanin ( Sfm_Ntk_t p,
int  iNode,
int  iFanin 
)

Definition at line 269 of file sfmNtk.c.

270 {
271  if ( iFanin < 0 )
272  return;
273  assert( Sfm_ObjIsNode(p, iNode) );
274  assert( !Sfm_ObjIsPo(p, iFanin) );
275  assert( Vec_IntFind( Sfm_ObjFiArray(p, iNode), iFanin ) == -1 );
276  assert( Vec_IntFind( Sfm_ObjFoArray(p, iFanin), iNode ) == -1 );
277  Vec_IntPush( Sfm_ObjFiArray(p, iNode), iFanin );
278  Vec_IntPush( Sfm_ObjFoArray(p, iFanin), iNode );
279 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntFind(Vec_Int_t *p, int Entry)
Definition: vecInt.h:895
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static int Sfm_ObjIsPo(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:130
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
#define assert(ex)
Definition: util_old.h:213
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 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file sfmNtk.c.

168 {
169  Sfm_Ntk_t * p;
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  ABC_FREE( vFanins );
182  // attributes
183  Sfm_CreateFanout( &p->vFanins, &p->vFanouts );
184  Sfm_CreateLevel( &p->vFanins, &p->vLevels, vEmpty );
185  Sfm_CreateLevelR( &p->vFanouts, &p->vLevelsR, vEmpty );
186  Vec_IntFill( &p->vCounts, p->nObjs, 0 );
187  Vec_IntFill( &p->vTravIds, p->nObjs, 0 );
188  Vec_IntFill( &p->vTravIds2, p->nObjs, 0 );
189  Vec_IntFill( &p->vId2Var, 2*p->nObjs, -1 );
190  Vec_IntFill( &p->vVar2Id, 2*p->nObjs, -1 );
191  p->vCover = Vec_IntAlloc( 1 << 16 );
192  p->vCnfs = Sfm_CreateCnf( p );
193  return p;
194 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
Definition: sfm.h:41
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
void Sfm_CreateLevel(Vec_Wec_t *vFanins, Vec_Int_t *vLevels, Vec_Str_t *vEmpty)
Definition: sfmNtk.c:118
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Sfm_CreateFanout(Vec_Wec_t *vFanins, Vec_Wec_t *vFanouts)
Definition: sfmNtk.c:76
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
Vec_Wec_t * Sfm_CreateCnf(Sfm_Ntk_t *p)
Definition: sfmCnf.c:122
void Sfm_CreateLevelR(Vec_Wec_t *vFanouts, Vec_Int_t *vLevelsR, Vec_Str_t *vEmpty)
Definition: sfmNtk.c:146
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
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_NtkDeleteObj_rec ( Sfm_Ntk_t p,
int  iNode 
)

Definition at line 280 of file sfmNtk.c.

281 {
282  int i, iFanin;
283  if ( Sfm_ObjFanoutNum(p, iNode) > 0 || Sfm_ObjIsPi(p, iNode) || Sfm_ObjIsFixed(p, iNode) )
284  return;
285  assert( Sfm_ObjIsNode(p, iNode) );
286  Sfm_ObjForEachFanin( p, iNode, iFanin, i )
287  {
288  int RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode ); assert( RetValue );
289  Sfm_NtkDeleteObj_rec( p, iFanin );
290  }
291  Vec_IntClear( Sfm_ObjFiArray(p, iNode) );
292  Vec_WrdWriteEntry( p->vTruths, iNode, (word)0 );
293 }
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition: sfmInt.h:172
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static int Sfm_ObjIsPi(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:129
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
void Sfm_NtkDeleteObj_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:280
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
Definition: vecInt.h:915
static int Sfm_ObjFanoutNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:140
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
#define assert(ex)
Definition: util_old.h:213
static int Sfm_ObjIsFixed(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:132
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Sfm_NtkFree ( Sfm_Ntk_t p)

Definition at line 213 of file sfmNtk.c.

214 {
215  // user data
216  Vec_StrFree( p->vFixed );
217  Vec_StrFreeP( &p->vEmpty );
218  Vec_WrdFree( p->vTruths );
219  Vec_WecErase( &p->vFanins );
220  // attributes
221  Vec_WecErase( &p->vFanouts );
222  ABC_FREE( p->vLevels.pArray );
223  ABC_FREE( p->vLevelsR.pArray );
224  ABC_FREE( p->vCounts.pArray );
225  ABC_FREE( p->vTravIds.pArray );
226  ABC_FREE( p->vTravIds2.pArray );
227  ABC_FREE( p->vId2Var.pArray );
228  ABC_FREE( p->vVar2Id.pArray );
229  Vec_WecFree( p->vCnfs );
230  Vec_IntFree( p->vCover );
231  // other data
232  Vec_IntFreeP( &p->vNodes );
233  Vec_IntFreeP( &p->vDivs );
234  Vec_IntFreeP( &p->vRoots );
235  Vec_IntFreeP( &p->vTfo );
236  Vec_WrdFreeP( &p->vDivCexes );
237  Vec_IntFreeP( &p->vOrder );
238  Vec_IntFreeP( &p->vDivVars );
239  Vec_IntFreeP( &p->vDivIds );
240  Vec_IntFreeP( &p->vLits );
241  Vec_IntFreeP( &p->vValues );
242  Vec_WecFreeP( &p->vClauses );
243  Vec_IntFreeP( &p->vFaninMap );
244  if ( p->pSat ) sat_solver_delete( p->pSat );
245  ABC_FREE( p );
246 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_WecFree(Vec_Wec_t *p)
Definition: vecWec.h:345
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Vec_Ptr_t * vRoots
Definition: llb3Image.c:51
static void Vec_WrdFreeP(Vec_Wrd_t **p)
Definition: vecWrd.h:277
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static void Vec_WecErase(Vec_Wec_t *p)
Definition: vecWec.h:336
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_WecFreeP(Vec_Wec_t **p)
Definition: vecWec.h:350
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_StrFreeP(Vec_Str_t **p)
Definition: vecStr.h:233
void Sfm_NtkPrepare ( Sfm_Ntk_t p)

Definition at line 195 of file sfmNtk.c.

196 {
197  p->nLevelMax = Vec_IntFindMax(&p->vLevels) + p->pPars->nGrowthLevel;
198  p->vNodes = Vec_IntAlloc( 1000 );
199  p->vDivs = Vec_IntAlloc( 100 );
200  p->vRoots = Vec_IntAlloc( 1000 );
201  p->vTfo = Vec_IntAlloc( 1000 );
202  p->vDivCexes = Vec_WrdStart( p->pPars->nWinSizeMax );
203  p->vOrder = Vec_IntAlloc( 100 );
204  p->vDivVars = Vec_IntAlloc( 100 );
205  p->vDivIds = Vec_IntAlloc( 1000 );
206  p->vLits = Vec_IntAlloc( 100 );
207  p->vValues = Vec_IntAlloc( 100 );
208  p->vClauses = Vec_WecAlloc( 100 );
209  p->vFaninMap = Vec_IntAlloc( 10 );
210  p->pSat = sat_solver_new();
211  sat_solver_setnvars( p->pSat, p->pPars->nWinSizeMax );
212 }
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vRoots
Definition: llb3Image.c:51
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
static int Vec_IntFindMax(Vec_Int_t *p)
Definition: vecInt.h:996
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
void Sfm_NtkRemoveFanin ( Sfm_Ntk_t p,
int  iNode,
int  iFanin 
)

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

Synopsis [Performs resubstitution for the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 259 of file sfmNtk.c.

260 {
261  int RetValue;
262  assert( Sfm_ObjIsNode(p, iNode) );
263  assert( !Sfm_ObjIsPo(p, iFanin) );
264  RetValue = Vec_IntRemove( Sfm_ObjFiArray(p, iNode), iFanin );
265  assert( RetValue );
266  RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode );
267  assert( RetValue );
268 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static int Sfm_ObjIsPo(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:130
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
Definition: vecInt.h:915
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
#define assert(ex)
Definition: util_old.h:213
void Sfm_NtkUpdate ( Sfm_Ntk_t p,
int  iNode,
int  f,
int  iFaninNew,
word  uTruth 
)

Definition at line 314 of file sfmNtk.c.

315 {
316  int iFanin = Sfm_ObjFanin( p, iNode, f );
317  assert( Sfm_ObjIsNode(p, iNode) );
318  assert( iFanin != iFaninNew );
319  if ( uTruth == 0 || ~uTruth == 0 )
320  {
321  Sfm_ObjForEachFanin( p, iNode, iFanin, f )
322  {
323  int RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode ); assert( RetValue );
324  Sfm_NtkDeleteObj_rec( p, iFanin );
325  }
326  Vec_IntClear( Sfm_ObjFiArray(p, iNode) );
327  }
328  else
329  {
330  // replace old fanin by new fanin
331  Sfm_NtkRemoveFanin( p, iNode, iFanin );
332  Sfm_NtkAddFanin( p, iNode, iFaninNew );
333  // recursively remove MFFC
334  Sfm_NtkDeleteObj_rec( p, iFanin );
335  }
336  // update logic level
337  Sfm_NtkUpdateLevel_rec( p, iNode );
338  if ( iFaninNew != -1 )
339  Sfm_NtkUpdateLevelR_rec( p, iFaninNew );
340  if ( Sfm_ObjFanoutNum(p, iFanin) > 0 )
341  Sfm_NtkUpdateLevelR_rec( p, iFanin );
342  // update truth table
343  Vec_WrdWriteEntry( p->vTruths, iNode, uTruth );
344  Sfm_TruthToCnf( uTruth, Sfm_ObjFaninNum(p, iNode), p->vCover, (Vec_Str_t *)Vec_WecEntry(p->vCnfs, iNode) );
345 }
void Sfm_NtkUpdateLevelR_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:304
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition: sfmInt.h:172
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Sfm_NtkRemoveFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
Definition: sfmNtk.c:259
static int Sfm_ObjFaninNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:139
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static int Sfm_ObjFanin(Sfm_Ntk_t *p, int i, int k)
Definition: sfmInt.h:145
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
void Sfm_NtkDeleteObj_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:280
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
Definition: vecInt.h:915
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
int Sfm_TruthToCnf(word Truth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Definition: sfmCnf.c:71
static int Sfm_ObjFanoutNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:140
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
#define assert(ex)
Definition: util_old.h:213
void Sfm_NtkAddFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
Definition: sfmNtk.c:269
void Sfm_NtkUpdateLevel_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:294
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Sfm_NtkUpdateLevel_rec ( Sfm_Ntk_t p,
int  iNode 
)

Definition at line 294 of file sfmNtk.c.

295 {
296  int i, iFanout;
297  int LevelNew = Sfm_ObjLevelNew( Sfm_ObjFiArray(p, iNode), &p->vLevels, Sfm_ObjAddsLevel(p, iNode) );
298  if ( LevelNew == Sfm_ObjLevel(p, iNode) )
299  return;
300  Sfm_ObjSetLevel( p, iNode, LevelNew );
301  Sfm_ObjForEachFanout( p, iNode, iFanout, i )
302  Sfm_NtkUpdateLevel_rec( p, iFanout );
303 }
static int Sfm_ObjAddsLevel(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:134
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjLevel(Sfm_Ntk_t *p, int iObj)
Definition: sfmInt.h:153
#define Sfm_ObjForEachFanout(p, Node, Fan, i)
Definition: sfmInt.h:173
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Sfm_ObjLevelNew(Vec_Int_t *vArray, Vec_Int_t *vLevels, int fAddLevel)
Definition: sfmNtk.c:111
static void Sfm_ObjSetLevel(Sfm_Ntk_t *p, int iObj, int Lev)
Definition: sfmInt.h:154
void Sfm_NtkUpdateLevel_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:294
void Sfm_NtkUpdateLevelR_rec ( Sfm_Ntk_t p,
int  iNode 
)

Definition at line 304 of file sfmNtk.c.

305 {
306  int i, iFanin;
307  int LevelNew = Sfm_ObjLevelNewR( Sfm_ObjFoArray(p, iNode), &p->vLevelsR, Sfm_ObjAddsLevel(p, iNode) );
308  if ( LevelNew == Sfm_ObjLevelR(p, iNode) )
309  return;
310  Sfm_ObjSetLevelR( p, iNode, LevelNew );
311  Sfm_ObjForEachFanin( p, iNode, iFanin, i )
312  Sfm_NtkUpdateLevelR_rec( p, iFanin );
313 }
static int Sfm_ObjAddsLevel(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:134
void Sfm_NtkUpdateLevelR_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:304
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition: sfmInt.h:172
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjLevelNewR(Vec_Int_t *vArray, Vec_Int_t *vLevelsR, int fAddLevel)
Definition: sfmNtk.c:139
static int Sfm_ObjLevelR(Sfm_Ntk_t *p, int iObj)
Definition: sfmInt.h:156
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
static void Sfm_ObjSetLevelR(Sfm_Ntk_t *p, int iObj, int Lev)
Definition: sfmInt.h:157
static int Sfm_ObjLevelNew ( Vec_Int_t vArray,
Vec_Int_t vLevels,
int  fAddLevel 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file sfmNtk.c.

112 {
113  int k, Fanin, Level = 0;
114  Vec_IntForEachEntry( vArray, Fanin, k )
115  Level = Abc_MaxInt( Level, Vec_IntEntry(vLevels, Fanin) );
116  return Level + fAddLevel;
117 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Sfm_ObjLevelNewR ( Vec_Int_t vArray,
Vec_Int_t vLevelsR,
int  fAddLevel 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file sfmNtk.c.

140 {
141  int k, Fanout, LevelR = 0;
142  Vec_IntForEachEntry( vArray, Fanout, k )
143  LevelR = Abc_MaxInt( LevelR, Vec_IntEntry(vLevelsR, Fanout) );
144  return LevelR + fAddLevel;
145 }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54