abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcFpgaFast.c File Reference
#include "base/abc/abc.h"
#include "aig/ivy/ivy.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Ivy_Man_t
Abc_NtkIvyBefore (Abc_Ntk_t *pNtk, int fSeq, int fUseDc)
 DECLARATIONS ///. More...
 
static Abc_Ntk_tIvy_ManFpgaToAbc (Abc_Ntk_t *pNtk, Ivy_Man_t *pMan)
 
static Abc_Obj_tIvy_ManToAbcFast_rec (Abc_Ntk_t *pNtkNew, Ivy_Man_t *pMan, Ivy_Obj_t *pObjIvy, Vec_Int_t *vNodes)
 
static void Abc_ObjSetIvy2Abc (Ivy_Man_t *p, int IvyId, Abc_Obj_t *pObjAbc)
 
static Abc_Obj_tAbc_ObjGetIvy2Abc (Ivy_Man_t *p, int IvyId)
 
Abc_Ntk_tAbc_NtkFpgaFast (Abc_Ntk_t *pNtk, int nLutSize, int fRecovery, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

Abc_Ntk_t* Abc_NtkFpgaFast ( Abc_Ntk_t pNtk,
int  nLutSize,
int  fRecovery,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Performs fast FPGA mapping of the network.]

Description [Takes the AIG to be mapped, the LUT size, and verbosity flag. Produces the new network by fast FPGA mapping of the current network. If the current network in ABC in not an AIG, the user should run command "strash" to make sure that the current network into an AIG before calling this procedure.]

SideEffects []

SeeAlso []

Definition at line 58 of file abcFpgaFast.c.

59 {
60  Ivy_Man_t * pMan;
61  Abc_Ntk_t * pNtkNew;
62  // make sure the network is an AIG
63  assert( Abc_NtkIsStrash(pNtk) );
64  // convert the network into the AIG
65  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
66  // perform fast FPGA mapping
67  Ivy_FastMapPerform( pMan, nLutSize, fRecovery, fVerbose );
68  // convert back into the ABC network
69  pNtkNew = Ivy_ManFpgaToAbc( pNtk, pMan );
70  Ivy_FastMapStop( pMan );
71  Ivy_ManStop( pMan );
72  // make sure that the final network passes the test
73  if ( pNtkNew != NULL && !Abc_NtkCheck( pNtkNew ) )
74  {
75  printf( "Abc_NtkFastMap: The network check has failed.\n" );
76  Abc_NtkDelete( pNtkNew );
77  return NULL;
78  }
79  return pNtkNew;
80 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static Abc_Ntk_t * Ivy_ManFpgaToAbc(Abc_Ntk_t *pNtk, Ivy_Man_t *pMan)
Definition: abcFpgaFast.c:93
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
void Ivy_ManStop(Ivy_Man_t *p)
Definition: ivyMan.c:238
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_NAMESPACE_IMPL_START Ivy_Man_t * Abc_NtkIvyBefore(Abc_Ntk_t *pNtk, int fSeq, int fUseDc)
DECLARATIONS ///.
Definition: abcIvy.c:84
void Ivy_FastMapStop(Ivy_Man_t *pAig)
Definition: ivyFastMap.c:194
void Ivy_FastMapPerform(Ivy_Man_t *pAig, int nLimit, int fRecovery, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: ivyFastMap.c:105
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition: ivy.h:46
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START Ivy_Man_t* Abc_NtkIvyBefore ( Abc_Ntk_t pNtk,
int  fSeq,
int  fUseDc 
)

DECLARATIONS ///.

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

FileName [abcFpgaFast.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Fast FPGA mapper.]

Author [Sungmin Cho]

Affiliation [UC Berkeley]

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

Revision [

Id:
abcFpgaFast.c,v 1.00 2006/09/02 00:00:00 alanmi Exp

]

DECLARATIONS ///.

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

Synopsis [Prepares the IVY package.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file abcIvy.c.

85 {
86  Ivy_Man_t * pMan;
87 //timeRetime = Abc_Clock();
88  assert( !Abc_NtkIsNetlist(pNtk) );
89  if ( Abc_NtkIsBddLogic(pNtk) )
90  {
91  if ( !Abc_NtkBddToSop(pNtk, 0) )
92  {
93  printf( "Abc_NtkIvyBefore(): Converting to SOPs has failed.\n" );
94  return NULL;
95  }
96  }
97  if ( fSeq && Abc_NtkCountSelfFeedLatches(pNtk) )
98  {
99  printf( "Warning: The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtk) );
100 // return NULL;
101  }
102  // print warning about choice nodes
103  if ( Abc_NtkGetChoiceNum( pNtk ) )
104  printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" );
105  // convert to the AIG manager
106  pMan = Abc_NtkToIvy( pNtk );
107  if ( !Ivy_ManCheck( pMan ) )
108  {
109  printf( "AIG check has failed.\n" );
110  Ivy_ManStop( pMan );
111  return NULL;
112  }
113 // Ivy_ManPrintStats( pMan );
114  if ( fSeq )
115  {
116  int nLatches = Abc_NtkLatchNum(pNtk);
117  Vec_Int_t * vInit = Abc_NtkCollectLatchValuesIvy( pNtk, fUseDc );
118  Ivy_ManMakeSeq( pMan, nLatches, vInit->pArray );
119  Vec_IntFree( vInit );
120 // Ivy_ManPrintStats( pMan );
121  }
122 //timeRetime = Abc_Clock() - timeRetime;
123  return pMan;
124 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
void Ivy_ManMakeSeq(Ivy_Man_t *p, int nLatches, int *pInits)
Definition: ivyMan.c:482
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
void Ivy_ManStop(Ivy_Man_t *p)
Definition: ivyMan.c:238
static Vec_Int_t * Abc_NtkCollectLatchValuesIvy(Abc_Ntk_t *pNtk, int fUseDcs)
Definition: abcIvy.c:1119
static Ivy_Man_t * Abc_NtkToIvy(Abc_Ntk_t *pNtkOld)
Definition: abcIvy.c:892
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition: ivy.h:46
ABC_DLL int Abc_NtkBddToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:359
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:265
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
ABC_DLL int Abc_NtkCountSelfFeedLatches(Abc_Ntk_t *pNtk)
Definition: abcLatch.c:89
int Ivy_ManCheck(Ivy_Man_t *p)
DECLARATIONS ///.
Definition: ivyCheck.c:45
static Abc_Obj_t* Abc_ObjGetIvy2Abc ( Ivy_Man_t p,
int  IvyId 
)
inlinestatic

Definition at line 37 of file abcFpgaFast.c.

37 { return (Abc_Obj_t *)Vec_PtrEntry( (Vec_Ptr_t *)p->pCopy, IvyId ); }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void Abc_ObjSetIvy2Abc ( Ivy_Man_t p,
int  IvyId,
Abc_Obj_t pObjAbc 
)
inlinestatic

Definition at line 36 of file abcFpgaFast.c.

36 { assert(Vec_PtrEntry((Vec_Ptr_t *)p->pCopy, IvyId) == NULL); assert(!Abc_ObjIsComplement(pObjAbc)); Vec_PtrWriteEntry( (Vec_Ptr_t *)p->pCopy, IvyId, pObjAbc ); }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
Abc_Ntk_t * Ivy_ManFpgaToAbc ( Abc_Ntk_t pNtk,
Ivy_Man_t pMan 
)
static

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

Synopsis [Constructs the ABC network after mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 93 of file abcFpgaFast.c.

94 {
95  Abc_Ntk_t * pNtkNew;
96  Abc_Obj_t * pObjAbc, * pObj;
97  Ivy_Obj_t * pObjIvy;
98  Vec_Int_t * vNodes;
99  int i;
100  // start mapping from Ivy into Abc
101  pMan->pCopy = Vec_PtrStart( Ivy_ManObjIdMax(pMan) + 1 );
102  // start the new ABC network
103  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_AIG );
104  // transfer the pointers to the basic nodes
105  Abc_ObjSetIvy2Abc( pMan, Ivy_ManConst1(pMan)->Id, Abc_NtkCreateNodeConst1(pNtkNew) );
106  Abc_NtkForEachCi( pNtkNew, pObjAbc, i )
107  Abc_ObjSetIvy2Abc( pMan, Ivy_ManPi(pMan, i)->Id, pObjAbc );
108  // recursively construct the network
109  vNodes = Vec_IntAlloc( 100 );
110  Ivy_ManForEachPo( pMan, pObjIvy, i )
111  {
112  // get the new ABC node corresponding to the old fanin of the PO in IVY
113  pObjAbc = Ivy_ManToAbcFast_rec( pNtkNew, pMan, Ivy_ObjFanin0(pObjIvy), vNodes );
114  // consider the case of complemented fanin of the PO
115  if ( Ivy_ObjFaninC0(pObjIvy) ) // complement
116  {
117  if ( Abc_ObjIsCi(pObjAbc) )
118  pObjAbc = Abc_NtkCreateNodeInv( pNtkNew, pObjAbc );
119  else
120  {
121  // clone the node
122  pObj = Abc_NtkCloneObj( pObjAbc );
123  // set complemented functions
124  pObj->pData = Hop_Not( (Hop_Obj_t *)pObjAbc->pData );
125  // return the new node
126  pObjAbc = pObj;
127  }
128  }
129  Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), pObjAbc );
130  }
131  Vec_IntFree( vNodes );
132  Vec_PtrFree( (Vec_Ptr_t *)pMan->pCopy );
133  pMan->pCopy = NULL;
134  // remove dangling nodes
135  Abc_NtkCleanup( pNtkNew, 0 );
136  // fix CIs feeding directly into COs
137  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
138  return pNtkNew;
139 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Ivy_Obj_t * Ivy_ManConst1(Ivy_Man_t *p)
Definition: ivy.h:199
static Ivy_Obj_t * Ivy_ManPi(Ivy_Man_t *p, int i)
Definition: ivy.h:201
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Ivy_ManForEachPo(p, pObj, i)
Definition: ivy.h:390
static Abc_Obj_t * Ivy_ManToAbcFast_rec(Abc_Ntk_t *pNtkNew, Ivy_Man_t *pMan, Ivy_Obj_t *pObjIvy, Vec_Int_t *vNodes)
Definition: abcFpgaFast.c:152
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
ABC_DLL Abc_Obj_t * Abc_NtkCloneObj(Abc_Obj_t *pNode)
Definition: abcObj.c:434
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSweep.c:476
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
Definition: hop.h:127
Definition: hop.h:65
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
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static int Ivy_ManObjIdMax(Ivy_Man_t *p)
Definition: ivy.h:226
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
Definition: ivy.h:73
static void Abc_ObjSetIvy2Abc(Ivy_Man_t *p, int IvyId, Abc_Obj_t *pObjAbc)
Definition: abcFpgaFast.c:36
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
void * pData
Definition: abc.h:145
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Ivy_ObjFaninC0(Ivy_Obj_t *pObj)
Definition: ivy.h:269
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Obj_t * Ivy_ManToAbcFast_rec ( Abc_Ntk_t pNtkNew,
Ivy_Man_t pMan,
Ivy_Obj_t pObjIvy,
Vec_Int_t vNodes 
)
static

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

Synopsis [Recursively construct the new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 152 of file abcFpgaFast.c.

153 {
154  Vec_Int_t Supp, * vSupp = &Supp;
155  Abc_Obj_t * pObjAbc, * pFaninAbc;
156  Ivy_Obj_t * pNodeIvy;
157  int i, Entry;
158  // skip the node if it is a constant or already processed
159  pObjAbc = Abc_ObjGetIvy2Abc( pMan, pObjIvy->Id );
160  if ( pObjAbc )
161  return pObjAbc;
162  assert( Ivy_ObjIsAnd(pObjIvy) || Ivy_ObjIsExor(pObjIvy) );
163  // get the support of K-LUT
164  Ivy_FastMapReadSupp( pMan, pObjIvy, vSupp );
165  // create new ABC node and its fanins
166  pObjAbc = Abc_NtkCreateNode( pNtkNew );
167  Vec_IntForEachEntry( vSupp, Entry, i )
168  {
169  pFaninAbc = Ivy_ManToAbcFast_rec( pNtkNew, pMan, Ivy_ManObj(pMan, Entry), vNodes );
170  Abc_ObjAddFanin( pObjAbc, pFaninAbc );
171  }
172  // collect the nodes used in the cut
173  Ivy_ManCollectCut( pMan, pObjIvy, vSupp, vNodes );
174  // create the local function
175  Ivy_ManForEachNodeVec( pMan, vNodes, pNodeIvy, i )
176  {
177  if ( i < Vec_IntSize(vSupp) )
178  pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_IthVar( (Hop_Man_t *)pNtkNew->pManFunc, i );
179  else
180  pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_And( (Hop_Man_t *)pNtkNew->pManFunc, (Hop_Obj_t *)Ivy_ObjChild0Equiv(pNodeIvy), (Hop_Obj_t *)Ivy_ObjChild1Equiv(pNodeIvy) );
181  }
182  // set the local function
183  pObjAbc->pData = (Abc_Obj_t *)pObjIvy->pEquiv;
184  // set the node
185  Abc_ObjSetIvy2Abc( pMan, pObjIvy->Id, pObjAbc );
186  return pObjAbc;
187 }
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Abc_Obj_t * Ivy_ManToAbcFast_rec(Abc_Ntk_t *pNtkNew, Ivy_Man_t *pMan, Ivy_Obj_t *pObjIvy, Vec_Int_t *vNodes)
Definition: abcFpgaFast.c:152
static Abc_Obj_t * Abc_ObjGetIvy2Abc(Ivy_Man_t *p, int IvyId)
Definition: abcFpgaFast.c:37
int Id
Definition: ivy.h:75
Definition: hop.h:65
static Ivy_Obj_t * Ivy_ObjChild1Equiv(Ivy_Obj_t *pObj)
Definition: ivy.h:276
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
static Ivy_Obj_t * Ivy_ManObj(Ivy_Man_t *p, int i)
Definition: ivy.h:203
static Ivy_Obj_t * Ivy_ObjChild0Equiv(Ivy_Obj_t *pObj)
Definition: ivy.h:275
Definition: ivy.h:73
void Ivy_ManCollectCut(Ivy_Man_t *p, Ivy_Obj_t *pRoot, Vec_Int_t *vLeaves, Vec_Int_t *vNodes)
Definition: ivyUtil.c:106
static void Abc_ObjSetIvy2Abc(Ivy_Man_t *p, int IvyId, Abc_Obj_t *pObjAbc)
Definition: abcFpgaFast.c:36
static int Ivy_ObjIsAnd(Ivy_Obj_t *pObj)
Definition: ivy.h:242
static int Ivy_ObjIsExor(Ivy_Obj_t *pObj)
Definition: ivy.h:243
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Ivy_ManForEachNodeVec(p, vIds, pObj, i)
Definition: ivy.h:408
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
void Ivy_FastMapReadSupp(Ivy_Man_t *pAig, Ivy_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition: ivyFastMap.c:793
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
Ivy_Obj_t * pEquiv
Definition: ivy.h:93