ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcFpgaFast.c
Go to the documentation of this file.
1
20
21#include "base/abc/abc.h"
22#include "aig/ivy/ivy.h"
23
25
26
30
31extern Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc );
32
33static Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan );
34static Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj_t * pObjIvy, Vec_Int_t * vNodes );
35
36static inline void Abc_ObjSetIvy2Abc( Ivy_Man_t * p, int IvyId, Abc_Obj_t * pObjAbc ) { assert(Vec_PtrEntry((Vec_Ptr_t *)p->pCopy, IvyId) == NULL); assert(!Abc_ObjIsComplement(pObjAbc)); Vec_PtrWriteEntry( (Vec_Ptr_t *)p->pCopy, IvyId, pObjAbc ); }
37static inline Abc_Obj_t * Abc_ObjGetIvy2Abc( Ivy_Man_t * p, int IvyId ) { return (Abc_Obj_t *)Vec_PtrEntry( (Vec_Ptr_t *)p->pCopy, IvyId ); }
38
42
58Abc_Ntk_t * Abc_NtkFpgaFast( Abc_Ntk_t * pNtk, int nLutSize, int fRecovery, int fVerbose )
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}
81
93Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan )
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}
140
152Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj_t * pObjIvy, Vec_Int_t * vNodes )
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}
188
192
193
195
Abc_Ntk_t * Abc_NtkFpgaFast(Abc_Ntk_t *pNtk, int nLutSize, int fRecovery, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition abcFpgaFast.c:58
ABC_NAMESPACE_IMPL_START Ivy_Man_t * Abc_NtkIvyBefore(Abc_Ntk_t *pNtk, int fSeq, int fUseDc)
DECLARATIONS ///.
Definition abcIvy.c:88
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition abcSweep.c:478
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition abcUtil.c:1080
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:674
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Obj_t * Abc_NtkCloneObj(Abc_Obj_t *pNode)
Definition abcObj.c:442
@ ABC_FUNC_AIG
Definition abc.h:67
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:157
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
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
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition hopOper.c:104
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition ivy.h:46
void Ivy_FastMapStop(Ivy_Man_t *pAig)
Definition ivyFastMap.c:194
#define Ivy_ManForEachPo(p, pObj, i)
Definition ivy.h:390
void Ivy_ManStop(Ivy_Man_t *p)
Definition ivyMan.c:238
struct Ivy_Obj_t_ Ivy_Obj_t
Definition ivy.h:47
#define Ivy_ManForEachNodeVec(p, vIds, pObj, i)
Definition ivy.h:408
void Ivy_ManCollectCut(Ivy_Man_t *p, Ivy_Obj_t *pRoot, Vec_Int_t *vLeaves, Vec_Int_t *vNodes)
Definition ivyUtil.c:106
void Ivy_FastMapReadSupp(Ivy_Man_t *pAig, Ivy_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition ivyFastMap.c:793
void Ivy_FastMapPerform(Ivy_Man_t *pAig, int nLimit, int fRecovery, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition ivyFastMap.c:105
void * pManFunc
Definition abc.h:191
void * pData
Definition abc.h:145
Ivy_Obj_t * pEquiv
Definition ivy.h:93
int Id
Definition ivy.h:75
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42