00001
00021 #include "abc.h"
00022 #include "ivy.h"
00023
00027
00028 extern Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc );
00029
00030 static Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan );
00031 static Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj_t * pObjIvy, Vec_Int_t * vNodes );
00032
00033 static inline void Abc_ObjSetIvy2Abc( Ivy_Man_t * p, int IvyId, Abc_Obj_t * pObjAbc ) { assert(Vec_PtrEntry(p->pCopy, IvyId) == NULL); assert(!Abc_ObjIsComplement(pObjAbc)); Vec_PtrWriteEntry( p->pCopy, IvyId, pObjAbc ); }
00034 static inline Abc_Obj_t * Abc_ObjGetIvy2Abc( Ivy_Man_t * p, int IvyId ) { return Vec_PtrEntry( p->pCopy, IvyId ); }
00035
00039
00055 Abc_Ntk_t * Abc_NtkFpgaFast( Abc_Ntk_t * pNtk, int nLutSize, int fRecovery, int fVerbose )
00056 {
00057 Ivy_Man_t * pMan;
00058 Abc_Ntk_t * pNtkNew;
00059
00060 assert( Abc_NtkIsStrash(pNtk) );
00061
00062 pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
00063
00064 Ivy_FastMapPerform( pMan, nLutSize, fRecovery, fVerbose );
00065
00066 pNtkNew = Ivy_ManFpgaToAbc( pNtk, pMan );
00067 Ivy_FastMapStop( pMan );
00068 Ivy_ManStop( pMan );
00069
00070 if ( pNtkNew != NULL && !Abc_NtkCheck( pNtkNew ) )
00071 {
00072 printf( "Abc_NtkFastMap: The network check has failed.\n" );
00073 Abc_NtkDelete( pNtkNew );
00074 return NULL;
00075 }
00076 return pNtkNew;
00077 }
00078
00090 Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan )
00091 {
00092 Abc_Ntk_t * pNtkNew;
00093 Abc_Obj_t * pObjAbc, * pObj;
00094 Ivy_Obj_t * pObjIvy;
00095 Vec_Int_t * vNodes;
00096 int i;
00097
00098 pMan->pCopy = Vec_PtrStart( Ivy_ManObjIdMax(pMan) + 1 );
00099
00100 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_AIG );
00101
00102 Abc_ObjSetIvy2Abc( pMan, Ivy_ManConst1(pMan)->Id, Abc_NtkCreateNodeConst1(pNtkNew) );
00103 Abc_NtkForEachCi( pNtkNew, pObjAbc, i )
00104 Abc_ObjSetIvy2Abc( pMan, Ivy_ManPi(pMan, i)->Id, pObjAbc );
00105
00106 vNodes = Vec_IntAlloc( 100 );
00107 Ivy_ManForEachPo( pMan, pObjIvy, i )
00108 {
00109
00110 pObjAbc = Ivy_ManToAbcFast_rec( pNtkNew, pMan, Ivy_ObjFanin0(pObjIvy), vNodes );
00111
00112 if ( Ivy_ObjFaninC0(pObjIvy) )
00113 {
00114 if ( Abc_ObjIsCi(pObjAbc) )
00115 pObjAbc = Abc_NtkCreateNodeInv( pNtkNew, pObjAbc );
00116 else
00117 {
00118
00119 pObj = Abc_NtkCloneObj( pObjAbc );
00120
00121 pObj->pData = Hop_Not( pObjAbc->pData );
00122
00123 pObjAbc = pObj;
00124 }
00125 }
00126 Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), pObjAbc );
00127 }
00128 Vec_IntFree( vNodes );
00129 Vec_PtrFree( pMan->pCopy );
00130 pMan->pCopy = NULL;
00131
00132 Abc_NtkCleanup( pNtkNew, 0 );
00133
00134 Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
00135 return pNtkNew;
00136 }
00137
00149 Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj_t * pObjIvy, Vec_Int_t * vNodes )
00150 {
00151 Vec_Int_t Supp, * vSupp = &Supp;
00152 Abc_Obj_t * pObjAbc, * pFaninAbc;
00153 Ivy_Obj_t * pNodeIvy;
00154 int i, Entry;
00155
00156 pObjAbc = Abc_ObjGetIvy2Abc( pMan, pObjIvy->Id );
00157 if ( pObjAbc )
00158 return pObjAbc;
00159 assert( Ivy_ObjIsAnd(pObjIvy) || Ivy_ObjIsExor(pObjIvy) );
00160
00161 Ivy_FastMapReadSupp( pMan, pObjIvy, vSupp );
00162
00163 pObjAbc = Abc_NtkCreateNode( pNtkNew );
00164 Vec_IntForEachEntry( vSupp, Entry, i )
00165 {
00166 pFaninAbc = Ivy_ManToAbcFast_rec( pNtkNew, pMan, Ivy_ManObj(pMan, Entry), vNodes );
00167 Abc_ObjAddFanin( pObjAbc, pFaninAbc );
00168 }
00169
00170 Ivy_ManCollectCut( pMan, pObjIvy, vSupp, vNodes );
00171
00172 Ivy_ManForEachNodeVec( pMan, vNodes, pNodeIvy, i )
00173 {
00174 if ( i < Vec_IntSize(vSupp) )
00175 pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_IthVar( pNtkNew->pManFunc, i );
00176 else
00177 pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_And( pNtkNew->pManFunc, (Hop_Obj_t *)Ivy_ObjChild0Equiv(pNodeIvy), (Hop_Obj_t *)Ivy_ObjChild1Equiv(pNodeIvy) );
00178 }
00179
00180 pObjAbc->pData = (Abc_Obj_t *)pObjIvy->pEquiv;
00181
00182 Abc_ObjSetIvy2Abc( pMan, pObjIvy->Id, pObjAbc );
00183 return pObjAbc;
00184 }
00185
00189
00190