00001
00021 #include "abc.h"
00022
00023
00024 #include "place_base.h"
00025
00029
00030 AbstractCell *abstractCells = NULL;
00031 ConcreteCell *cells = NULL;
00032 ConcreteNet *nets = NULL;
00033 int nAllocSize = 0;
00034
00038
00050 static inline void Abc_PlaceCreateCell( Abc_Obj_t * pObj, int fAnd )
00051 {
00052 assert( cells[pObj->Id].m_id == 0 );
00053
00054 cells[pObj->Id].m_id = pObj->Id;
00055 cells[pObj->Id].m_label = "";
00056 cells[pObj->Id].m_parent = &(abstractCells[fAnd]);
00057 cells[pObj->Id].m_fixed = 0;
00058 addConcreteCell(&(cells[pObj->Id]));
00059 }
00060
00072 static inline void Abc_PlaceUpdateNet( Abc_Obj_t * pObj )
00073 {
00074 Abc_Obj_t * pFanout;
00075 int k;
00076
00077 if ( nets[pObj->Id].m_terms )
00078 free( nets[pObj->Id].m_terms );
00079
00080 nets[pObj->Id].m_id = pObj->Id;
00081 nets[pObj->Id].m_weight = 1.0;
00082 nets[pObj->Id].m_numTerms = Abc_ObjFanoutNum(pObj);
00083 nets[pObj->Id].m_terms = ALLOC(ConcreteCell*, Abc_ObjFanoutNum(pObj));
00084 Abc_ObjForEachFanout( pObj, pFanout, k )
00085 nets[pObj->Id].m_terms[k] = &(cells[pFanout->Id]);
00086 addConcreteNet(&(nets[pObj->Id]));
00087 }
00088
00100 float Abc_PlaceEvaluateCut( Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins )
00101 {
00102 Abc_Obj_t * pObj;
00103
00104 int i;
00105 Vec_PtrForEachEntry( vFanins, pObj, i )
00106 {
00107
00108 }
00109 return 0.0;
00110 }
00111
00123 void Abc_PlaceUpdate( Vec_Ptr_t * vAddedCells, Vec_Ptr_t * vUpdatedNets )
00124 {
00125 Abc_Obj_t * pObj, * pFanin;
00126 int i, k;
00127 Vec_Ptr_t * vCells, * vNets;
00128
00129
00130 vCells = Vec_PtrAlloc( 16 );
00131 vNets = Vec_PtrAlloc( 32 );
00132
00133
00134 Vec_PtrForEachEntry( vAddedCells, pObj, i )
00135 {
00136 assert( !Abc_ObjIsComplement(pObj) );
00137 Abc_PlaceCreateCell( pObj, 1 );
00138 Abc_PlaceUpdateNet( pObj );
00139
00140
00141 Vec_PtrPush( vCells, &(cells[pObj->Id]) );
00142 Abc_ObjForEachFanin( pObj, pFanin, k )
00143 Vec_PtrPushUnique( vNets, &(nets[pFanin->Id]) );
00144 }
00145
00146
00147 Vec_PtrForEachEntry( vUpdatedNets, pObj, i )
00148 {
00149 assert( !Abc_ObjIsComplement(pObj) );
00150 if ( Abc_ObjType(pObj) == ABC_OBJ_NONE )
00151 continue;
00152 Abc_PlaceUpdateNet( pObj );
00153 }
00154
00155
00156
00157
00158
00159
00160 Vec_PtrFree( vCells );
00161 Vec_PtrFree( vNets );
00162 }
00163
00175 void Abc_PlaceBegin( Abc_Ntk_t * pNtk )
00176 {
00177 Abc_Obj_t * pObj;
00178 int i;
00179
00180
00181 nAllocSize = 5 * Abc_NtkObjNumMax(pNtk);
00182 cells = REALLOC(ConcreteCell, cells, nAllocSize);
00183 nets = REALLOC(ConcreteNet, nets, nAllocSize);
00184 memset( cells, 0, sizeof(ConcreteCell) * nAllocSize );
00185 memset( nets, 0, sizeof(ConcreteNet) * nAllocSize );
00186
00187
00188
00189
00190 if (!abstractCells)
00191 abstractCells = ALLOC(AbstractCell,2);
00192
00193 abstractCells[0].m_height = 1.0;
00194 abstractCells[0].m_width = 1.0;
00195 abstractCells[0].m_label = "pio";
00196 abstractCells[0].m_pad = 1;
00197
00198 abstractCells[1].m_height = 1.0;
00199 abstractCells[1].m_width = 1.0;
00200 abstractCells[1].m_label = "and";
00201 abstractCells[1].m_pad = 0;
00202
00203
00204 Abc_NtkForEachCi( pNtk, pObj, i )
00205 Abc_PlaceCreateCell( pObj, 0 );
00206
00207
00208 Abc_NtkForEachCo( pNtk, pObj, i )
00209 Abc_PlaceCreateCell( pObj, 0 );
00210
00211
00212 Abc_AigForEachAnd( pNtk, pObj, i )
00213 Abc_PlaceCreateCell( pObj, 1 );
00214
00215
00216 Abc_NtkForEachObj( pNtk, pObj, i )
00217 {
00218 if ( !Abc_ObjIsCi(pObj) && !Abc_ObjIsNode(pObj) )
00219 continue;
00220 Abc_PlaceUpdateNet( pObj );
00221 }
00222
00223 globalPreplace((float)0.8);
00224 globalPlace();
00225 }
00226
00238 void Abc_PlaceEnd( Abc_Ntk_t * pNtk )
00239 {
00240 int i;
00241
00242
00243
00244 for ( i = 0; i < nAllocSize; i++ )
00245 FREE( nets[i].m_terms );
00246 FREE( abstractCells );
00247 FREE( cells );
00248 FREE( nets );
00249 }
00250
00254
00255