abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcPlace.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcPlace.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Interface with a placer.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcPlace.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 
23 // placement includes
24 #include "phys/place/place_base.h"
25 
27 
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// DECLARATIONS ///
31 ////////////////////////////////////////////////////////////////////////
32 
35 ConcreteNet *nets = NULL;
36 int nAllocSize = 0;
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// FUNCTION DEFINITIONS ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 /**Function*************************************************************
43 
44  Synopsis [Creates a new cell.]
45 
46  Description []
47 
48  SideEffects []
49 
50  SeeAlso []
51 
52 ***********************************************************************/
53 static inline void Abc_PlaceCreateCell( Abc_Obj_t * pObj, int fAnd )
54 {
55  assert( cells[pObj->Id].m_id == 0 );
56 
57  cells[pObj->Id].m_id = pObj->Id;
58  cells[pObj->Id].m_label = "";
59  cells[pObj->Id].m_parent = &(abstractCells[fAnd]);
60  cells[pObj->Id].m_fixed = 0;
61  addConcreteCell(&(cells[pObj->Id]));
62 }
63 
64 /**Function*************************************************************
65 
66  Synopsis [Updates the net.]
67 
68  Description []
69 
70  SideEffects []
71 
72  SeeAlso []
73 
74 ***********************************************************************/
75 static inline void Abc_PlaceUpdateNet( Abc_Obj_t * pObj )
76 {
77  Abc_Obj_t * pFanout;
78  int k;
79  // free the old array of net terminals
80  if ( nets[pObj->Id].m_terms )
81  free( nets[pObj->Id].m_terms );
82  // fill in the net with the new information
83  nets[pObj->Id].m_id = pObj->Id;
84  nets[pObj->Id].m_weight = 1.0;
85  nets[pObj->Id].m_numTerms = Abc_ObjFanoutNum(pObj); //fanout
86  nets[pObj->Id].m_terms = ALLOC(ConcreteCell*, Abc_ObjFanoutNum(pObj));
87  Abc_ObjForEachFanout( pObj, pFanout, k )
88  nets[pObj->Id].m_terms[k] = &(cells[pFanout->Id]);
89  addConcreteNet(&(nets[pObj->Id]));
90 }
91 
92 /**Function*************************************************************
93 
94  Synopsis [Returns the placement cost of the cut.]
95 
96  Description []
97 
98  SideEffects []
99 
100  SeeAlso []
101 
102 ***********************************************************************/
103 float Abc_PlaceEvaluateCut( Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins )
104 {
105  Abc_Obj_t * pObj;
106 // double x, y;
107  int i;
108  Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i )
109  {
110 // pObj->Id
111  }
112  return 0.0;
113 }
114 
115 /**Function*************************************************************
116 
117  Synopsis [Updates placement after one step of rewriting.]
118 
119  Description []
120 
121  SideEffects []
122 
123  SeeAlso []
124 
125 ***********************************************************************/
126 void Abc_PlaceUpdate( Vec_Ptr_t * vAddedCells, Vec_Ptr_t * vUpdatedNets )
127 {
128  Abc_Obj_t * pObj, * pFanin;
129  int i, k;
130  Vec_Ptr_t * vCells, * vNets;
131 
132  // start the arrays of new cells and nets
133  vCells = Vec_PtrAlloc( 16 );
134  vNets = Vec_PtrAlloc( 32 );
135 
136  // go through the new nodes
137  Vec_PtrForEachEntry( Abc_Obj_t *, vAddedCells, pObj, i )
138  {
139  assert( !Abc_ObjIsComplement(pObj) );
140  Abc_PlaceCreateCell( pObj, 1 );
141  Abc_PlaceUpdateNet( pObj );
142 
143  // add the new cell and its fanin nets to temporary storage
144  Vec_PtrPush( vCells, &(cells[pObj->Id]) );
145  Abc_ObjForEachFanin( pObj, pFanin, k )
146  Vec_PtrPushUnique( vNets, &(nets[pFanin->Id]) );
147  }
148 
149  // go through the modified nets
150  Vec_PtrForEachEntry( Abc_Obj_t *, vUpdatedNets, pObj, i )
151  {
152  assert( !Abc_ObjIsComplement(pObj) );
153  if ( Abc_ObjType(pObj) == ABC_OBJ_NONE ) // dead node
154  continue;
155  Abc_PlaceUpdateNet( pObj );
156  }
157 
158  // update the placement
159 // fastPlace( Vec_PtrSize(vCells), (ConcreteCell **)Vec_PtrArray(vCells),
160 // Vec_PtrSize(vNets), (ConcreteNet **)Vec_PtrArray(vNets) );
161 
162  // clean up
163  Vec_PtrFree( vCells );
164  Vec_PtrFree( vNets );
165 }
166 
167 /**Function*************************************************************
168 
169  Synopsis [This procedure is called before the writing start.]
170 
171  Description []
172 
173  SideEffects []
174 
175  SeeAlso []
176 
177 ***********************************************************************/
178 void Abc_PlaceBegin( Abc_Ntk_t * pNtk )
179 {
180  Abc_Obj_t * pObj;
181  int i;
182 
183  // allocate and clean internal storage
184  nAllocSize = 5 * Abc_NtkObjNumMax(pNtk);
185  cells = REALLOC(ConcreteCell, cells, nAllocSize);
186  nets = REALLOC(ConcreteNet, nets, nAllocSize);
187  memset( cells, 0, sizeof(ConcreteCell) * nAllocSize );
188  memset( nets, 0, sizeof(ConcreteNet) * nAllocSize );
189 
190  // create AbstractCells
191  // 1: pad
192  // 2: and
193  if (!abstractCells)
194  abstractCells = ALLOC(AbstractCell,2);
195 
196  abstractCells[0].m_height = 1.0;
197  abstractCells[0].m_width = 1.0;
198  abstractCells[0].m_label = "pio";
199  abstractCells[0].m_pad = 1;
200 
201  abstractCells[1].m_height = 1.0;
202  abstractCells[1].m_width = 1.0;
203  abstractCells[1].m_label = "and";
204  abstractCells[1].m_pad = 0;
205 
206  // input pads
207  Abc_NtkForEachCi( pNtk, pObj, i )
208  Abc_PlaceCreateCell( pObj, 0 );
209 
210  // ouput pads
211  Abc_NtkForEachCo( pNtk, pObj, i )
212  Abc_PlaceCreateCell( pObj, 0 );
213 
214  // AND nodes
215  Abc_AigForEachAnd( pNtk, pObj, i )
216  Abc_PlaceCreateCell( pObj, 1 );
217 
218  // all nets
219  Abc_NtkForEachObj( pNtk, pObj, i )
220  {
221  if ( !Abc_ObjIsCi(pObj) && !Abc_ObjIsNode(pObj) )
222  continue;
223  Abc_PlaceUpdateNet( pObj );
224  }
225 
226  globalPreplace((float)0.8);
227  globalPlace();
228 }
229 
230 /**Function*************************************************************
231 
232  Synopsis [This procedure is called after the writing completes.]
233 
234  Description []
235 
236  SideEffects []
237 
238  SeeAlso []
239 
240 ***********************************************************************/
241 void Abc_PlaceEnd( Abc_Ntk_t * pNtk )
242 {
243  int i;
244 
245 
246  // clean up
247  for ( i = 0; i < nAllocSize; i++ )
248  FREE( nets[i].m_terms );
249  FREE( abstractCells );
250  FREE( cells );
251  FREE( nets );
252 }
253 
254 ////////////////////////////////////////////////////////////////////////
255 /// END OF FILE ///
256 ////////////////////////////////////////////////////////////////////////
257 
258 
260 
char * memset()
AbstractCell * m_parent
Definition: place_base.h:57
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
VOID_HACK free()
ConcreteCell * cells
Definition: abcPlace.c:34
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void globalPlace()
Performs analytic placement using a GORDIAN-like algorithm.
Definition: place_gordian.c:39
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
float m_width
Definition: place_base.h:45
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
void Abc_PlaceUpdate(Vec_Ptr_t *vAddedCells, Vec_Ptr_t *vUpdatedNets)
Definition: abcPlace.c:126
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_NAMESPACE_IMPL_START AbstractCell * abstractCells
DECLARATIONS ///.
Definition: abcPlace.c:33
void addConcreteNet(ConcreteNet *net)
Adds a net to the placement database.
Definition: place_base.c:114
float m_weight
Definition: place_base.h:74
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
void Abc_PlaceBegin(Abc_Ntk_t *pNtk)
Definition: abcPlace.c:178
char * m_label
Definition: place_base.h:55
ConcreteNet * nets
Definition: abcPlace.c:35
float Abc_PlaceEvaluateCut(Abc_Obj_t *pRoot, Vec_Ptr_t *vFanins)
Definition: abcPlace.c:103
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
bool m_fixed
Definition: place_base.h:59
void addConcreteCell(ConcreteCell *cell)
Definition: place_base.c:155
ConcreteCell ** m_terms
Definition: place_base.h:72
#define ALLOC(type, num)
Definition: avl.h:27
float m_height
Definition: place_base.h:45
static unsigned Abc_ObjType(Abc_Obj_t *pObj)
Definition: abc.h:328
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define FREE(obj)
Definition: avl.h:31
void globalPreplace(float utilization)
Place pad ring, leaving a core area to meet a desired utilization.
Definition: place_pads.c:31
int m_numTerms
Definition: place_base.h:71
#define REALLOC(type, obj, num)
Definition: avl.h:29
char * m_label
Definition: place_base.h:43
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void Abc_PlaceCreateCell(Abc_Obj_t *pObj, int fAnd)
FUNCTION DEFINITIONS ///.
Definition: abcPlace.c:53
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
void Abc_PlaceEnd(Abc_Ntk_t *pNtk)
Definition: abcPlace.c:241
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Abc_PlaceUpdateNet(Abc_Obj_t *pObj)
Definition: abcPlace.c:75
int nAllocSize
Definition: abcPlace.c:36
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223