abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcMfs.c File Reference
#include "base/abc/abc.h"
#include "bool/kit/kit.h"
#include "opt/sfm/sfm.h"
#include "base/io/ioAbc.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Vec_Ptr_t
Abc_NtkAssignIDs (Abc_Ntk_t *pNtk)
 DECLARATIONS ///. More...
 
Vec_Ptr_tAbc_NtkAssignIDs2 (Abc_Ntk_t *pNtk)
 
Sfm_Ntk_tAbc_NtkExtractMfs (Abc_Ntk_t *pNtk, int nFirstFixed)
 
Sfm_Ntk_tAbc_NtkExtractMfs2 (Abc_Ntk_t *pNtk, int iPivot)
 
void Abc_NtkInsertMfs (Abc_Ntk_t *pNtk, Sfm_Ntk_t *p)
 
int Abc_NtkPerformMfs (Abc_Ntk_t *pNtk, Sfm_Par_t *pPars)
 
Abc_Ntk_tAbc_NtkUnrollAndDrop (Abc_Ntk_t *p, int nFrames, int nFramesAdd, Vec_Int_t *vFlops, int *piPivot)
 
void Abc_NtkReinsertNodes (Abc_Ntk_t *p, Abc_Ntk_t *pNtk, int iPivot)
 
int Abc_NtkMfsAfterICheck (Abc_Ntk_t *p, int nFrames, int nFramesAdd, Vec_Int_t *vFlops, Sfm_Par_t *pPars)
 

Function Documentation

ABC_NAMESPACE_IMPL_START Vec_Ptr_t* Abc_NtkAssignIDs ( Abc_Ntk_t pNtk)

DECLARATIONS ///.

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

FileName [abcMfs.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Optimization with don't-cares.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file abcMfs.c.

49 {
50  Vec_Ptr_t * vNodes;
51  Abc_Obj_t * pObj;
52  int i;
53  vNodes = Abc_NtkDfs( pNtk, 0 );
54  Abc_NtkCleanCopy( pNtk );
55  Abc_NtkForEachCi( pNtk, pObj, i )
56  pObj->iTemp = i;
57  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
58  {
59  pObj->iTemp = Abc_NtkCiNum(pNtk) + i;
60 //printf( "%d->%d ", pObj->Id, pObj->iTemp );
61  }
62 //printf( "\n" );
63  Abc_NtkForEachCo( pNtk, pObj, i )
64  pObj->iTemp = Abc_NtkCiNum(pNtk) + Vec_PtrSize(vNodes) + i;
65  return vNodes;
66 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Vec_Ptr_t* Abc_NtkAssignIDs2 ( Abc_Ntk_t pNtk)

Definition at line 67 of file abcMfs.c.

68 {
69  Vec_Ptr_t * vNodes;
70  Abc_Obj_t * pObj;
71  int i;
72  Abc_NtkCleanCopy( pNtk );
73  Abc_NtkForEachCi( pNtk, pObj, i )
74  pObj->iTemp = i;
75  vNodes = Vec_PtrAlloc( Abc_NtkNodeNum(pNtk) );
76  Abc_NtkForEachNode( pNtk, pObj, i )
77  {
78  pObj->iTemp = Abc_NtkCiNum(pNtk) + Vec_PtrSize(vNodes);
79  Vec_PtrPush( vNodes, pObj );
80  }
81  assert( Vec_PtrSize(vNodes) == Abc_NtkNodeNum(pNtk) );
82  Abc_NtkForEachCo( pNtk, pObj, i )
83  pObj->iTemp = Abc_NtkCiNum(pNtk) + Vec_PtrSize(vNodes) + i;
84  return vNodes;
85 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
Sfm_Ntk_t* Abc_NtkExtractMfs ( Abc_Ntk_t pNtk,
int  nFirstFixed 
)

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

Synopsis [Extracts information about the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file abcMfs.c.

99 {
100  Vec_Ptr_t * vNodes;
101  Vec_Wec_t * vFanins;
102  Vec_Str_t * vFixed;
103  Vec_Wrd_t * vTruths;
104  Vec_Int_t * vArray;
105  Abc_Obj_t * pObj, * pFanin;
106  int i, k, nObjs;
107  vNodes = nFirstFixed ? Abc_NtkAssignIDs2(pNtk) : Abc_NtkAssignIDs(pNtk);
108  nObjs = Abc_NtkCiNum(pNtk) + Vec_PtrSize(vNodes) + Abc_NtkCoNum(pNtk);
109  vFanins = Vec_WecStart( nObjs );
110  vFixed = Vec_StrStart( nObjs );
111  vTruths = Vec_WrdStart( nObjs );
112  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
113  {
114  word uTruth = Abc_SopToTruth((char *)pObj->pData, Abc_ObjFaninNum(pObj));
115  Vec_WrdWriteEntry( vTruths, pObj->iTemp, uTruth );
116  if ( uTruth == 0 || ~uTruth == 0 )
117  continue;
118  vArray = Vec_WecEntry( vFanins, pObj->iTemp );
119  Vec_IntGrow( vArray, Abc_ObjFaninNum(pObj) );
120  Abc_ObjForEachFanin( pObj, pFanin, k )
121  Vec_IntPush( vArray, pFanin->iTemp );
122  }
123  Abc_NtkForEachCo( pNtk, pObj, i )
124  {
125  vArray = Vec_WecEntry( vFanins, pObj->iTemp );
126  Vec_IntGrow( vArray, Abc_ObjFaninNum(pObj) );
127  Abc_ObjForEachFanin( pObj, pFanin, k )
128  Vec_IntPush( vArray, pFanin->iTemp );
129  }
130  Vec_PtrFree( vNodes );
131  for ( i = Abc_NtkCiNum(pNtk); i < Abc_NtkCiNum(pNtk) + nFirstFixed; i++ )
132  Vec_StrWriteEntry( vFixed, i, (char)1 );
133  // update fixed
134  assert( nFirstFixed >= 0 && nFirstFixed < Abc_NtkNodeNum(pNtk) );
135 // for ( i = Abc_NtkCiNum(pNtk); i + Abc_NtkCoNum(pNtk) < Abc_NtkObjNum(pNtk); i++ )
136 // if ( rand() % 10 == 0 )
137 // Vec_StrWriteEntry( vFixed, i, (char)1 );
138  return Sfm_NtkConstruct( vFanins, Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), vFixed, NULL, vTruths );
139 }
int iTemp
Definition: abc.h:149
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition: vecWec.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Ptr_t * Abc_NtkAssignIDs2(Abc_Ntk_t *pNtk)
Definition: abcMfs.c:67
static Vec_Wec_t * Vec_WecStart(int nSize)
Definition: vecWec.h:98
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
for(p=first;p->value< newval;p=p->next)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static Vec_Str_t * Vec_StrStart(int nSize)
Definition: vecStr.h:95
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
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)
Definition: sfmNtk.c:167
ABC_DLL word Abc_SopToTruth(char *pSop, int nInputs)
Definition: abcSop.c:1163
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_NAMESPACE_IMPL_START Vec_Ptr_t * Abc_NtkAssignIDs(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: abcMfs.c:48
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Sfm_Ntk_t* Abc_NtkExtractMfs2 ( Abc_Ntk_t pNtk,
int  iPivot 
)

Definition at line 140 of file abcMfs.c.

141 {
142  Vec_Ptr_t * vNodes;
143  Vec_Wec_t * vFanins;
144  Vec_Str_t * vFixed;
145  Vec_Wrd_t * vTruths;
146  Vec_Int_t * vArray;
147  Abc_Obj_t * pObj, * pFanin;
148  int i, k, nObjs;
149  vNodes = Abc_NtkAssignIDs2(pNtk);
150  nObjs = Abc_NtkCiNum(pNtk) + Vec_PtrSize(vNodes) + Abc_NtkCoNum(pNtk);
151  vFanins = Vec_WecStart( nObjs );
152  vFixed = Vec_StrStart( nObjs );
153  vTruths = Vec_WrdStart( nObjs );
154  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
155  {
156  word uTruth = Abc_SopToTruth((char *)pObj->pData, Abc_ObjFaninNum(pObj));
157  Vec_WrdWriteEntry( vTruths, pObj->iTemp, uTruth );
158  if ( uTruth == 0 || ~uTruth == 0 )
159  continue;
160  vArray = Vec_WecEntry( vFanins, pObj->iTemp );
161  Vec_IntGrow( vArray, Abc_ObjFaninNum(pObj) );
162  Abc_ObjForEachFanin( pObj, pFanin, k )
163  Vec_IntPush( vArray, pFanin->iTemp );
164  }
165  Abc_NtkForEachCo( pNtk, pObj, i )
166  {
167  vArray = Vec_WecEntry( vFanins, pObj->iTemp );
168  Vec_IntGrow( vArray, Abc_ObjFaninNum(pObj) );
169  Abc_ObjForEachFanin( pObj, pFanin, k )
170  Vec_IntPush( vArray, pFanin->iTemp );
171  }
172  Vec_PtrFree( vNodes );
173  // set fixed attributes
174  Abc_NtkForEachNode( pNtk, pObj, i )
175  if ( i >= iPivot )
176  Vec_StrWriteEntry( vFixed, pObj->iTemp, (char)1 );
177  return Sfm_NtkConstruct( vFanins, Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), vFixed, NULL, vTruths );
178 }
int iTemp
Definition: abc.h:149
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition: vecWec.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Ptr_t * Abc_NtkAssignIDs2(Abc_Ntk_t *pNtk)
Definition: abcMfs.c:67
static Vec_Wec_t * Vec_WecStart(int nSize)
Definition: vecWec.h:98
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
Definition: bblif.c:336
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
static Vec_Str_t * Vec_StrStart(int nSize)
Definition: vecStr.h:95
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
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)
Definition: sfmNtk.c:167
ABC_DLL word Abc_SopToTruth(char *pSop, int nInputs)
Definition: abcSop.c:1163
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkInsertMfs ( Abc_Ntk_t pNtk,
Sfm_Ntk_t p 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file abcMfs.c.

192 {
193  Vec_Int_t * vCover, * vMap, * vArray;
194  Abc_Obj_t * pNode;
195  word * pTruth;
196  int i, k, Fanin;
197  // map new IDs into old nodes
198  vMap = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
199  Abc_NtkForEachCi( pNtk, pNode, i )
200  Vec_IntWriteEntry( vMap, pNode->iTemp, Abc_ObjId(pNode) );
201  Abc_NtkForEachNode( pNtk, pNode, i )
202  if ( pNode->iTemp > 0 )
203  Vec_IntWriteEntry( vMap, pNode->iTemp, Abc_ObjId(pNode) );
204  // remove old fanins
205  Abc_NtkForEachNode( pNtk, pNode, i )
206  if ( !Sfm_NodeReadFixed(p, pNode->iTemp) )
207  Abc_ObjRemoveFanins( pNode );
208  // create new fanins
209  vCover = Vec_IntAlloc( 1 << 16 );
210  Abc_NtkForEachNode( pNtk, pNode, i )
211  {
212  if ( pNode->iTemp == 0 || Sfm_NodeReadFixed(p, pNode->iTemp) )
213  continue;
214  if ( !Sfm_NodeReadUsed(p, pNode->iTemp) )
215  {
216  Abc_NtkDeleteObj( pNode );
217  continue;
218  }
219  // update fanins
220  vArray = Sfm_NodeReadFanins( p, pNode->iTemp );
221  Vec_IntForEachEntry( vArray, Fanin, k )
222  Abc_ObjAddFanin( pNode, Abc_NtkObj(pNtk, Vec_IntEntry(vMap, Fanin)) );
223  // update function
224  pTruth = Sfm_NodeReadTruth( p, pNode->iTemp );
225  if ( pTruth[0] == 0 )
226  pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 0\n" );
227  else if ( ~pTruth[0] == 0 )
228  pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, " 1\n" );
229  else
230  {
231  int RetValue = Kit_TruthIsop( (unsigned *)pTruth, Vec_IntSize(vArray), vCover, 1 );
232  assert( Vec_IntSize(vArray) > 0 );
233  assert( RetValue == 0 || RetValue == 1 );
234  pNode->pData = Abc_SopCreateFromIsop( (Mem_Flex_t *)pNtk->pManFunc, Vec_IntSize(vArray), vCover );
235  if ( RetValue )
236  Abc_SopComplement( (char *)pNode->pData );
237  }
238  assert( Abc_SopGetVarNum((char *)pNode->pData) == Vec_IntSize(vArray) );
239  }
240  Vec_IntFree( vCover );
241  Vec_IntFree( vMap );
242 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Sfm_NodeReadFanins(Sfm_Ntk_t *p, int i)
Definition: sfmNtk.c:358
ABC_DLL char * Abc_SopCreateFromIsop(Mem_Flex_t *pMan, int nVars, Vec_Int_t *vCover)
Definition: abcSop.c:416
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
int Sfm_NodeReadUsed(Sfm_Ntk_t *p, int i)
Definition: sfmNtk.c:370
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
Definition: abcFanio.c:141
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
ABC_DLL void Abc_SopComplement(char *pSop)
Definition: abcSop.c:600
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
int Sfm_NodeReadFixed(Sfm_Ntk_t *p, int i)
Definition: sfmNtk.c:366
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
word * Sfm_NodeReadTruth(Sfm_Ntk_t *p, int i)
Definition: sfmNtk.c:362
int Abc_NtkMfsAfterICheck ( Abc_Ntk_t p,
int  nFrames,
int  nFramesAdd,
Vec_Int_t vFlops,
Sfm_Par_t pPars 
)

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

Synopsis [Performs MFS for the unrolled network.]

Description []

SideEffects []

SeeAlso []

Definition at line 430 of file abcMfs.c.

431 {
432  Sfm_Ntk_t * pp;
433  int nFaninMax, nNodes;
434  Abc_Ntk_t * pNtk;
435  int iPivot;
436  assert( Abc_NtkIsLogic(p) );
437  // count fanouts
438  nFaninMax = Abc_NtkGetFaninMax( p );
439  if ( nFaninMax > 6 )
440  {
441  Abc_Print( 1, "Currently \"mfs\" cannot process the network containing nodes with more than 6 fanins.\n" );
442  return 0;
443  }
444  if ( !Abc_NtkHasSop(p) )
445  Abc_NtkToSop( p, 0 );
446  // derive unfolded network
447  pNtk = Abc_NtkUnrollAndDrop( p, nFrames, nFramesAdd, vFlops, &iPivot );
448  Io_WriteBlifLogic( pNtk, "unroll_dump.blif", 0 );
449  // collect information
450  pp = Abc_NtkExtractMfs2( pNtk, iPivot );
451  // perform optimization
452  nNodes = Sfm_NtkPerform( pp, pPars );
453  if ( nNodes == 0 )
454  {
455 // Abc_Print( 1, "The network is not changed by \"mfs\".\n" );
456  }
457  else
458  {
459  Abc_NtkInsertMfs( pNtk, pp );
460  if( pPars->fVerbose )
461  Abc_Print( 1, "The network has %d nodes changed by \"mfs\".\n", nNodes );
462  Abc_NtkReinsertNodes( p, pNtk, iPivot );
463  }
464  Abc_NtkDelete( pNtk );
465  Sfm_NtkFree( pp );
466  // perform final sweep
467  Abc_NtkSweep( p, 0 );
468  if ( !Abc_NtkHasSop(p) )
469  Abc_NtkToSop( p, 0 );
470  return 1;
471 
472 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
Sfm_Ntk_t * Abc_NtkExtractMfs2(Abc_Ntk_t *pNtk, int iPivot)
Definition: abcMfs.c:140
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
Definition: sfm.h:41
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int Sfm_NtkPerform(Sfm_Ntk_t *p, Sfm_Par_t *pPars)
Definition: sfmCore.c:257
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
void Abc_NtkInsertMfs(Abc_Ntk_t *pNtk, Sfm_Ntk_t *p)
Definition: abcMfs.c:191
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int fVerbose
Definition: sfm.h:56
void Sfm_NtkFree(Sfm_Ntk_t *p)
Definition: sfmNtk.c:213
ABC_DLL int Abc_NtkSweep(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSweep.c:574
Abc_Ntk_t * Abc_NtkUnrollAndDrop(Abc_Ntk_t *p, int nFrames, int nFramesAdd, Vec_Int_t *vFlops, int *piPivot)
Definition: abcMfs.c:300
void Io_WriteBlifLogic(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
FUNCTION DEFINITIONS ///.
Definition: ioWriteBlif.c:59
#define assert(ex)
Definition: util_old.h:213
void Abc_NtkReinsertNodes(Abc_Ntk_t *p, Abc_Ntk_t *pNtk, int iPivot)
Definition: abcMfs.c:378
int Abc_NtkPerformMfs ( Abc_Ntk_t pNtk,
Sfm_Par_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file abcMfs.c.

256 {
257  Sfm_Ntk_t * p;
258  int nFaninMax, nNodes;
259  assert( Abc_NtkIsLogic(pNtk) );
260  // count fanouts
261  nFaninMax = Abc_NtkGetFaninMax( pNtk );
262  if ( nFaninMax > 6 )
263  {
264  Abc_Print( 1, "Currently \"mfs\" cannot process the network containing nodes with more than 6 fanins.\n" );
265  return 0;
266  }
267  if ( !Abc_NtkHasSop(pNtk) )
268  Abc_NtkToSop( pNtk, 0 );
269  // collect information
270  p = Abc_NtkExtractMfs( pNtk, pPars->nFirstFixed );
271  // perform optimization
272  nNodes = Sfm_NtkPerform( p, pPars );
273  if ( nNodes == 0 )
274  {
275 // Abc_Print( 1, "The network is not changed by \"mfs\".\n" );
276  }
277  else
278  {
279  Abc_NtkInsertMfs( pNtk, p );
280  if( pPars->fVerbose )
281  Abc_Print( 1, "The network has %d nodes changed by \"mfs\".\n", nNodes );
282  }
283  Sfm_NtkFree( p );
284  return 1;
285 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
int nFirstFixed
Definition: sfm.h:52
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
Definition: sfm.h:41
int Sfm_NtkPerform(Sfm_Ntk_t *p, Sfm_Par_t *pPars)
Definition: sfmCore.c:257
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
void Abc_NtkInsertMfs(Abc_Ntk_t *pNtk, Sfm_Ntk_t *p)
Definition: abcMfs.c:191
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int fVerbose
Definition: sfm.h:56
void Sfm_NtkFree(Sfm_Ntk_t *p)
Definition: sfmNtk.c:213
#define assert(ex)
Definition: util_old.h:213
Sfm_Ntk_t * Abc_NtkExtractMfs(Abc_Ntk_t *pNtk, int nFirstFixed)
Definition: abcMfs.c:98
void Abc_NtkReinsertNodes ( Abc_Ntk_t p,
Abc_Ntk_t pNtk,
int  iPivot 
)

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

Synopsis [Updates the original network to include optimized nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 378 of file abcMfs.c.

379 {
380  Abc_Obj_t * pNode, * pNodeNew, * pFaninNew;
381  Vec_Ptr_t * vNodes;
382  int i, k;
383  assert( Abc_NtkIsLogic(p) );
384  assert( Abc_NtkCiNum(p) <= Abc_NtkCiNum(pNtk) );
385  vNodes = Abc_NtkDfs( p, 0 );
386  // clean old network
387  Abc_NtkCleanCopy( p );
388  Abc_NtkForEachNode( p, pNode, i )
389  {
390  Abc_ObjRemoveFanins( pNode );
391  pNode->pData = Abc_SopRegister( (Mem_Flex_t *)p->pManFunc, (char *)" 0\n" );
392  }
393  // map CIs
394  Abc_NtkForEachCi( p, pNode, i )
395  Abc_NtkCi(pNtk, i)->pCopy = pNode;
396  // map internal nodes
397  assert( Vec_PtrSize(vNodes) + Abc_NtkCiNum(p) + Abc_NtkPoNum(p) == iPivot );
398  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
399  {
400  pNodeNew = Abc_NtkObj( pNtk, Abc_NtkCiNum(p) + i );
401  if ( pNodeNew == NULL )
402  continue;
403  pNodeNew->pCopy = pNode;
404  }
405  // connect internal nodes
406  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
407  {
408  pNodeNew = Abc_NtkObj( pNtk, Abc_NtkCiNum(p) + i );
409  if ( pNodeNew == NULL )
410  continue;
411  assert( pNodeNew->pCopy == pNode );
412  Abc_ObjForEachFanin( pNodeNew, pFaninNew, k )
413  Abc_ObjAddFanin( pNodeNew->pCopy, pFaninNew->pCopy );
414  pNode->pData = Abc_SopRegister( (Mem_Flex_t *)p->pManFunc, (char *)pNodeNew->pData );
415  }
416  Vec_PtrFree( vNodes );
417 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
Definition: abcFanio.c:141
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t* Abc_NtkUnrollAndDrop ( Abc_Ntk_t p,
int  nFrames,
int  nFramesAdd,
Vec_Int_t vFlops,
int *  piPivot 
)

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

Synopsis [Unrolls logic network while dropping some next-state functions.]

Description [Returns the unrolled network.]

SideEffects []

SeeAlso []

Definition at line 300 of file abcMfs.c.

301 {
302  Abc_Ntk_t * pNtk;
303  Abc_Obj_t * pFanin, * pNode;
304  Vec_Ptr_t * vNodes;
305  int i, k, f, Value;
306  assert( nFramesAdd >= 0 );
307  assert( Abc_NtkIsLogic(p) );
308  assert( Vec_IntSize(vFlops) == Abc_NtkLatchNum(p) );
309  *piPivot = -1;
310  // start the network
311  pNtk = Abc_NtkAlloc( p->ntkType, p->ntkFunc, 1 );
312  pNtk->pName = Extra_UtilStrsav(Abc_NtkName(p));
313  // add CIs for the new network
314  Abc_NtkForEachCi( p, pNode, i )
315  pNode->pCopy = Abc_NtkCreatePi( pNtk );
316  // iterate unrolling
317  vNodes = Abc_NtkDfs( p, 0 );
318  for ( f = 0; f <= nFrames + nFramesAdd; f++ )
319  {
320  if ( f > 0 )
321  {
322  Abc_NtkForEachPi( p, pNode, i )
323  pNode->pCopy = Abc_NtkCreatePi( pNtk );
324  }
325  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
326  {
327  Abc_NtkDupObj( pNtk, pNode, 0 );
328  Abc_ObjForEachFanin( pNode, pFanin, k )
329  Abc_ObjAddFanin( pNode->pCopy, pFanin->pCopy );
330  }
331  Abc_NtkForEachCo( p, pNode, i )
332  pNode->pCopy = Abc_ObjFanin0(pNode)->pCopy;
333  Abc_NtkForEachPo( p, pNode, i )
334  Abc_ObjAddFanin( Abc_NtkCreatePo(pNtk), pNode->pCopy );
335  // add buffers
336  if ( f == 0 )
337  {
338  *piPivot = Abc_NtkObjNum(pNtk);
339 // Abc_NtkForEachLatchInput( p, pNode, i )
340 // pNode->pCopy = Abc_NtkCreateNodeBuf( pNtk, pNode->pCopy );
341  }
342  // transfer to flop outputs
343  Abc_NtkForEachLatch( p, pNode, i )
344  Abc_ObjFanout0(pNode)->pCopy = Abc_ObjFanin0(pNode)->pCopy;
345  // add final POs
346  if ( f > nFramesAdd )
347  {
348  Vec_IntForEachEntry( vFlops, Value, i )
349  {
350  if ( Value == 0 )
351  continue;
352  pNode = Abc_NtkCo( p, Abc_NtkPoNum(p) + i );
353  Abc_ObjAddFanin( Abc_NtkCreatePo(pNtk), pNode->pCopy );
354  }
355  }
356  }
357  Vec_PtrFree( vNodes );
358  Abc_NtkAddDummyPiNames( pNtk );
359  Abc_NtkAddDummyPoNames( pNtk );
360  // perform combinational cleanup
361  Abc_NtkCleanup( pNtk, 0 );
362  if ( !Abc_NtkCheck( pNtk ) )
363  fprintf( stdout, "Abc_NtkCreateFromNode(): Network check has failed.\n" );
364  return pNtk;
365 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSweep.c:476
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
char * Extra_UtilStrsav(const char *s)
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition: abcNtk.c:50
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:398
Abc_Obj_t * pCopy
Definition: abc.h:148
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
Abc_NtkFunc_t ntkFunc
Definition: abc.h:157
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Abc_NtkObjNum(Abc_Ntk_t *pNtk)
Definition: abc.h:283
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:378
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
char * pName
Definition: abc.h:158
Abc_NtkType_t ntkType
Definition: abc.h:156
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223