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