ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaMfs.c
Go to the documentation of this file.
1
20
21#include "gia.h"
22#include "opt/sfm/sfm.h"
23#include "misc/tim/tim.h"
24#include "misc/util/utilTruth.h"
25
27
31
35
48{
49 word uTruth, * pTruth, uTruths6[6] = {
50 ABC_CONST(0xAAAAAAAAAAAAAAAA),
51 ABC_CONST(0xCCCCCCCCCCCCCCCC),
52 ABC_CONST(0xF0F0F0F0F0F0F0F0),
53 ABC_CONST(0xFF00FF00FF00FF00),
54 ABC_CONST(0xFFFF0000FFFF0000),
55 ABC_CONST(0xFFFFFFFF00000000)
56 };
57 Gia_Obj_t * pObj, * pObjExtra;
58 Vec_Wec_t * vFanins; // mfs data
59 Vec_Str_t * vFixed; // mfs data
60 Vec_Str_t * vEmpty; // mfs data
61 Vec_Wrd_t * vTruths; // mfs data
62 Vec_Int_t * vArray;
63 Vec_Int_t * vStarts;
64 Vec_Wrd_t * vTruths2;
65 Vec_Int_t * vLeaves;
66 Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
67 int nBoxes = Gia_ManBoxNum(p), nVars;
68 int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p);
69 int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p);
70 int i, j, k, curCi, curCo, nBoxIns, nBoxOuts, w, nWords;
71 int Id, iFan, nMfsVars, nBbIns = 0, nBbOuts = 0, Counter = 0;
72 int nLutSizeMax = Gia_ManLutSizeMax( p );
73 nLutSizeMax = Abc_MaxInt( nLutSizeMax, 6 );
74 assert( nLutSizeMax < 16 );
75 //assert( !p->pAigExtra || Gia_ManPiNum(p->pAigExtra) <= 6 );
76 if ( pManTime ) Tim_ManBlackBoxIoNum( pManTime, &nBbIns, &nBbOuts );
77 // skip PIs due to box outputs
78 Counter += nBbOuts;
79 // prepare storage
80 nMfsVars = Gia_ManCiNum(p) + 1 + Gia_ManLutNum(p) + Gia_ManCoNum(p) + nBbIns + nBbOuts;
81 vFanins = Vec_WecStart( nMfsVars );
82 vFixed = Vec_StrStart( nMfsVars );
83 vEmpty = Vec_StrStart( nMfsVars );
84 vTruths = Vec_WrdStart( nMfsVars );
85 vStarts = Vec_IntStart( nMfsVars );
86 vTruths2 = Vec_WrdAlloc( 10000 );
87 // set internal PIs
88 Gia_ManCleanCopyArray( p );
89 Gia_ManForEachCiId( p, Id, i )
90 Gia_ObjSetCopyArray( p, Id, Counter++ );
91 // set constant node
92 Vec_StrWriteEntry( vFixed, Counter, (char)1 );
93 Vec_WrdWriteEntry( vTruths, Counter, (word)0 );
94 Gia_ObjSetCopyArray( p, 0, Counter++ );
95 // set internal LUTs
96 vLeaves = Vec_IntAlloc( nLutSizeMax );
97 Gia_ObjComputeTruthTableStart( p, nLutSizeMax );
98 Gia_ManForEachLut( p, Id )
99 {
100 Vec_IntClear( vLeaves );
101 vArray = Vec_WecEntry( vFanins, Counter );
102 Vec_IntGrow( vArray, Gia_ObjLutSize(p, Id) );
103 Gia_LutForEachFanin( p, Id, iFan, k )
104 {
105 assert( Gia_ObjCopyArray(p, iFan) >= 0 );
106 Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) );
107 Vec_IntPush( vLeaves, iFan );
108 }
109 assert( Vec_IntSize(vLeaves) < 16 );
110 assert( Vec_IntSize(vLeaves) == Gia_ObjLutSize(p, Id) );
111// uTruth = *Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, Id), vLeaves );
112// nVars = Abc_Tt6MinBase( &uTruth, Vec_IntArray(vArray), Vec_IntSize(vArray) );
113 pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, Id), vLeaves );
114 nVars = Abc_TtMinBase( pTruth, Vec_IntArray(vArray), Vec_IntSize(vArray), Vec_IntSize(vLeaves) );
115 Vec_IntShrink( vArray, nVars );
116 Vec_WrdWriteEntry( vTruths, Counter, pTruth[0] );
117 nWords = Abc_Truth6WordNum( nVars );
118 Vec_IntWriteEntry( vStarts, Counter, Vec_WrdSize(vTruths2) );
119 for ( w = 0; w < nWords; w++ )
120 Vec_WrdPush( vTruths2, pTruth[w] );
121 if ( Gia_ObjLutIsMux(p, Id) )
122 {
123 Vec_StrWriteEntry( vFixed, Counter, (char)1 );
124 Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
125 }
126 Gia_ObjSetCopyArray( p, Id, Counter++ );
127 }
129 // set all POs
130 Gia_ManForEachCo( p, pObj, i )
131 {
132 iFan = Gia_ObjFaninId0p( p, pObj );
133 assert( Gia_ObjCopyArray(p, iFan) >= 0 );
134 vArray = Vec_WecEntry( vFanins, Counter );
135 Vec_IntFill( vArray, 1, Gia_ObjCopyArray(p, iFan) );
136 if ( i < Gia_ManCoNum(p) - nRealPos ) // internal PO
137 {
138 Vec_StrWriteEntry( vFixed, Counter, (char)1 );
139 Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
140 uTruth = Gia_ObjFaninC0(pObj) ? ~uTruths6[0]: uTruths6[0];
141 Vec_WrdWriteEntry( vTruths, Counter, uTruth );
142 Vec_IntWriteEntry( vStarts, Counter, Vec_WrdSize(vTruths2) );
143 Vec_WrdPush( vTruths2, uTruth );
144 }
145 Gia_ObjSetCopyArray( p, Gia_ObjId(p, pObj), Counter++ );
146 }
147 // skip POs due to box inputs
148 Counter += nBbIns;
149 assert( Counter == nMfsVars );
150 // add functions of the boxes
151 if ( p->pAigExtra )
152 {
153 int iBbIn = 0, iBbOut = 0;
154 assert( Gia_ManCiNum(p->pAigExtra) < 16 );
155 Gia_ObjComputeTruthTableStart( p->pAigExtra, Gia_ManCiNum(p->pAigExtra) );
156 curCi = nRealPis;
157 curCo = 0;
158 for ( k = 0; k < nBoxes; k++ )
159 {
160 nBoxIns = Tim_ManBoxInputNum( pManTime, k );
161 nBoxOuts = Tim_ManBoxOutputNum( pManTime, k );
162 // iterate through box outputs
163 if ( !Tim_ManBoxIsBlack(pManTime, k) ) //&& Tim_ManBoxInputNum(pManTime, k) <= 6 )
164 {
165 // collect truth table leaves
166 Vec_IntClear( vLeaves );
167 for ( i = 0; i < nBoxIns; i++ )
168 Vec_IntPush( vLeaves, Gia_ObjId(p->pAigExtra, Gia_ManCi(p->pAigExtra, i)) );
169 for ( j = 0; j < nBoxOuts; j++ )
170 {
171 // CI corresponding to the box outputs
172 pObj = Gia_ManCi( p, curCi + j );
173 Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
174 // add box inputs (POs of the AIG) as fanins
175 vArray = Vec_WecEntry( vFanins, Counter );
176 Vec_IntGrow( vArray, nBoxIns );
177 for ( i = 0; i < nBoxIns; i++ )
178 {
179 iFan = Gia_ObjId( p, Gia_ManCo(p, curCo + i) );
180 assert( Gia_ObjCopyArray(p, iFan) >= 0 );
181 Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) );
182 }
183 Vec_StrWriteEntry( vFixed, Counter, (char)1 );
184 // box output in the extra manager
185 pObjExtra = Gia_ManCo( p->pAigExtra, curCi - nRealPis + j );
186 // compute truth table
187 pTruth = NULL;
188 if ( Gia_ObjFaninId0p(p->pAigExtra, pObjExtra) == 0 )
189 {
190 uTruth = 0;
191 uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth;
192 pTruth = &uTruth;
193 }
194 else if ( Gia_ObjIsCi(Gia_ObjFanin0(pObjExtra)) )
195 {
196 uTruth = uTruths6[Gia_ObjCioId(Gia_ObjFanin0(pObjExtra))];
197 uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth;
198 pTruth = &uTruth;
199 }
200 else
201 {
202 pTruth = Gia_ObjComputeTruthTableCut( p->pAigExtra, Gia_ObjFanin0(pObjExtra), vLeaves );
203 if ( Gia_ObjFaninC0(pObjExtra) )
204 Abc_TtNot( pTruth, Abc_Truth6WordNum(Vec_IntSize(vLeaves)) );
205 }
206 //uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth;
207 //Dau_DsdPrintFromTruth( &uTruth, Vec_IntSize(vArray) );
208 //nVars = Abc_Tt6MinBase( &uTruth, Vec_IntArray(vArray), Vec_IntSize(vArray) );
209 nVars = Abc_TtMinBase( pTruth, Vec_IntArray(vArray), Vec_IntSize(vArray), Vec_IntSize(vLeaves) );
210 Vec_IntShrink( vArray, nVars );
211 if ( nVars <= 6 )
212 Vec_WrdWriteEntry( vTruths, Counter, pTruth[0] );
213 else
214 {
215 int w, nWords = Abc_Truth6WordNum( nVars );
216 Vec_IntWriteEntry( vStarts, Counter, Vec_WrdSize(vTruths2) );
217 for ( w = 0; w < nWords; w++ )
218 Vec_WrdPush( vTruths2, pTruth[w] );
219 }
220 }
221 }
222 else // create buffers for black box inputs and outputs
223 {
224 for ( j = 0; j < nBoxOuts; j++ )
225 {
226 // CI corresponding to the box outputs
227 pObj = Gia_ManCi( p, curCi + j );
228 Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
229 // connect it with the special primary input (iBbOut)
230 vArray = Vec_WecEntry( vFanins, Counter );
231 assert( Vec_IntSize(vArray) == 0 );
232 Vec_IntFill( vArray, 1, iBbOut++ );
233 Vec_StrWriteEntry( vFixed, Counter, (char)1 );
234 Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
235 Vec_WrdWriteEntry( vTruths, Counter, uTruths6[0] );
236 }
237 for ( i = 0; i < nBoxIns; i++ )
238 {
239 // CO corresponding to the box inputs
240 pObj = Gia_ManCo( p, curCo + i );
241 Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
242 // connect it with the special primary output (iBbIn)
243 vArray = Vec_WecEntry( vFanins, nMfsVars - nBbIns + iBbIn++ );
244 assert( Vec_IntSize(vArray) == 0 );
245 Vec_IntFill( vArray, 1, Counter );
246 }
247 }
248 // set internal POs pointing directly to internal PIs as no-delay
249 for ( i = 0; i < nBoxIns; i++ )
250 {
251 pObj = Gia_ManCo( p, curCo + i );
252 if ( !Gia_ObjIsCi( Gia_ObjFanin0(pObj) ) )
253 continue;
254 Counter = Gia_ObjCopyArray( p, Gia_ObjFaninId0p(p, pObj) );
255 Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
256 }
257 curCo += nBoxIns;
258 curCi += nBoxOuts;
259 }
260 curCo += nRealPos;
261 Gia_ObjComputeTruthTableStop( p->pAigExtra );
262 // verify counts
263 assert( curCi == Gia_ManCiNum(p) );
264 assert( curCo == Gia_ManCoNum(p) );
265 assert( curCi - nRealPis == Gia_ManCoNum(p->pAigExtra) );
266 assert( iBbIn == nBbIns );
267 assert( iBbOut == nBbOuts );
268 }
269 // finalize
270 Vec_IntFree( vLeaves );
271 return Sfm_NtkConstruct( vFanins, nBbOuts + nRealPis, nRealPos + nBbIns, vFixed, vEmpty, vTruths, vStarts, vTruths2 );
272}
273
285Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk, int fAllBoxes )
286{
287 extern int Gia_ManFromIfLogicCreateLut( Gia_Man_t * pNew, word * pRes, Vec_Int_t * vLeaves, Vec_Int_t * vCover, Vec_Int_t * vMapping, Vec_Int_t * vMapping2 );
288 Gia_Man_t * pNew; Gia_Obj_t * pObj;
289 Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
290 int nBoxes = Gia_ManBoxNum(p);
291 int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p);
292 int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p);
293 int i, k, Id, curCi, curCo, nBoxIns, nBoxOuts, iLitNew, iMfsId, iGroup, Fanin;
294 int nMfsNodes;
295 word * pTruth, uTruthVar = ABC_CONST(0xAAAAAAAAAAAAAAAA);
296 Vec_Wec_t * vGroups = Vec_WecStart( nBoxes );
297 Vec_Int_t * vMfs2Gia, * vMfs2Old;
298 Vec_Int_t * vGroupMap;
299 Vec_Int_t * vMfsTopo, * vCover, * vBoxesLeft;
300 Vec_Int_t * vArray, * vLeaves;
301 Vec_Int_t * vMapping, * vMapping2;
302 int nBbIns = 0, nBbOuts = 0;
303 if ( pManTime ) Tim_ManBlackBoxIoNum( pManTime, &nBbIns, &nBbOuts );
304 nMfsNodes = 1 + Gia_ManCiNum(p) + Gia_ManLutNum(p) + Gia_ManCoNum(p) + nBbIns + nBbOuts;
305 vMfs2Gia = Vec_IntStartFull( nMfsNodes );
306 vMfs2Old = Vec_IntStartFull( nMfsNodes );
307 vGroupMap = Vec_IntStartFull( nMfsNodes );
308 Gia_ManForEachObj( p, pObj, i )
309 if ( Gia_ObjCopyArray(p, i) > 0 )
310 Vec_IntWriteEntry( vMfs2Old, Gia_ObjCopyArray(p, i), i );
311 // collect nodes
312 curCi = nRealPis;
313 curCo = 0;
314 for ( i = 0; i < nBoxes; i++ )
315 {
316 nBoxIns = Tim_ManBoxInputNum( pManTime, i );
317 nBoxOuts = Tim_ManBoxOutputNum( pManTime, i );
318 vArray = Vec_WecEntry( vGroups, i );
319 for ( k = 0; k < nBoxIns; k++ )
320 {
321 pObj = Gia_ManCo( p, curCo + k );
322 iMfsId = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
323 assert( iMfsId > 0 );
324 Vec_IntPush( vArray, iMfsId );
325 Vec_IntWriteEntry( vGroupMap, iMfsId, Abc_Var2Lit(i,0) );
326 }
327 for ( k = 0; k < nBoxOuts; k++ )
328 {
329 pObj = Gia_ManCi( p, curCi + k );
330 iMfsId = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
331 assert( iMfsId > 0 );
332 Vec_IntPush( vArray, iMfsId );
333 Vec_IntWriteEntry( vGroupMap, iMfsId, Abc_Var2Lit(i,1) );
334 }
335 curCo += nBoxIns;
336 curCi += nBoxOuts;
337 }
338 curCo += nRealPos;
339 assert( curCi == Gia_ManCiNum(p) );
340 assert( curCo == Gia_ManCoNum(p) );
341
342 // collect nodes in the given order
343 vBoxesLeft = Vec_IntAlloc( nBoxes );
344 vMfsTopo = Sfm_NtkDfs( pNtk, vGroups, vGroupMap, vBoxesLeft, fAllBoxes );
345 assert( Vec_IntSize(vBoxesLeft) <= nBoxes );
346 assert( Vec_IntSize(vMfsTopo) > 0 );
347
348 // start new GIA
349 pNew = Gia_ManStart( Gia_ManObjNum(p) );
350 pNew->pName = Abc_UtilStrsav( p->pName );
351 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
352
353 // start mapping
354 vMapping = Vec_IntStart( Gia_ManObjNum(p) );
355 vMapping2 = Vec_IntStart( 1 );
356 // create const LUT
357 Vec_IntWriteEntry( vMapping, 0, Vec_IntSize(vMapping2) );
358 Vec_IntPush( vMapping2, 0 );
359 Vec_IntPush( vMapping2, 0 );
360
361 // map constant
362 Vec_IntWriteEntry( vMfs2Gia, Gia_ObjCopyArray(p, 0), 0 );
363 // map primary inputs
364 Gia_ManForEachCiId( p, Id, i )
365 if ( i < nRealPis )
366 Vec_IntWriteEntry( vMfs2Gia, Gia_ObjCopyArray(p, Id), Gia_ManAppendCi(pNew) );
367 // map internal nodes
368 vLeaves = Vec_IntAlloc( 6 );
369 vCover = Vec_IntAlloc( 1 << 16 );
370 Vec_IntForEachEntry( vMfsTopo, iMfsId, i )
371 {
372 pTruth = Sfm_NodeReadTruth( pNtk, iMfsId );
373 iGroup = Vec_IntEntry( vGroupMap, iMfsId );
374 vArray = Sfm_NodeReadFanins( pNtk, iMfsId ); // belongs to pNtk
375 if ( Vec_IntSize(vArray) == 1 && Vec_IntEntry(vArray,0) < nBbOuts ) // skip unreal inputs
376 {
377 // create CI for the output of black box
378 assert( Abc_LitIsCompl(iGroup) );
379 iLitNew = Gia_ManAppendCi( pNew );
380 Vec_IntWriteEntry( vMfs2Gia, iMfsId, iLitNew );
381 continue;
382 }
383 Vec_IntClear( vLeaves );
384 Vec_IntForEachEntry( vArray, Fanin, k )
385 {
386 iLitNew = Vec_IntEntry( vMfs2Gia, Fanin ); assert( iLitNew >= 0 );
387 Vec_IntPush( vLeaves, iLitNew );
388 }
389 if ( iGroup == -1 ) // internal node
390 {
391 assert( Sfm_NodeReadUsed(pNtk, iMfsId) );
392 if ( Gia_ObjLutIsMux(p, Vec_IntEntry(vMfs2Old, iMfsId)) )
393 {
394 int MapSize = Vec_IntSize(vMapping2);
395 int nVarsNew;
396 Abc_TtSimplify( pTruth, Vec_IntArray(vLeaves), Vec_IntSize(vLeaves), &nVarsNew );
397 Vec_IntShrink( vLeaves, nVarsNew );
398 Abc_TtFlipVar5( pTruth, Vec_IntSize(vLeaves) );
399 iLitNew = Gia_ManFromIfLogicCreateLut( pNew, pTruth, vLeaves, vCover, vMapping, vMapping2 );
400 Abc_TtFlipVar5( pTruth, Vec_IntSize(vLeaves) );
401 if ( MapSize < Vec_IntSize(vMapping2) )
402 {
403 assert( Vec_IntEntryLast(vMapping2) == Abc_Lit2Var(iLitNew) );
404 Vec_IntWriteEntry(vMapping2, Vec_IntSize(vMapping2)-1, -Abc_Lit2Var(iLitNew) );
405 }
406 }
407 else
408 {
409 Abc_TtFlipVar5( pTruth, Vec_IntSize(vLeaves) );
410 iLitNew = Gia_ManFromIfLogicCreateLut( pNew, pTruth, vLeaves, vCover, vMapping, vMapping2 );
411 Abc_TtFlipVar5( pTruth, Vec_IntSize(vLeaves) );
412 }
413 }
414 else if ( Abc_LitIsCompl(iGroup) ) // internal CI
415 {
416 //Dau_DsdPrintFromTruth( pTruth, Vec_IntSize(vLeaves) );
417 iLitNew = Gia_ManAppendCi( pNew );
418 }
419 else // internal CO
420 {
421 assert( pTruth[0] == uTruthVar || pTruth[0] == ~uTruthVar );
422 iLitNew = Gia_ManAppendCo( pNew, Abc_LitNotCond(Vec_IntEntry(vLeaves, 0), pTruth[0] == ~uTruthVar) );
423 //printf("Group = %d. po = %d\n", iGroup>>1, iMfsId );
424 }
425 Vec_IntWriteEntry( vMfs2Gia, iMfsId, iLitNew );
426 }
427 Vec_IntFree( vCover );
428 Vec_IntFree( vLeaves );
429
430 // map primary outputs
431 Gia_ManForEachCo( p, pObj, i )
432 {
433 if ( i < Gia_ManCoNum(p) - nRealPos ) // internal COs
434 {
435 iMfsId = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
436 iGroup = Vec_IntEntry( vGroupMap, iMfsId );
437 if ( Vec_IntFind(vMfsTopo, iGroup) >= 0 )
438 {
439 iLitNew = Vec_IntEntry( vMfs2Gia, iMfsId );
440 if ( iLitNew < 0 )
441 continue;
442 assert( iLitNew >= 0 );
443 }
444 continue;
445 }
446 iLitNew = Vec_IntEntry( vMfs2Gia, Gia_ObjCopyArray(p, Gia_ObjFaninId0p(p, pObj)) );
447 assert( iLitNew >= 0 );
448 Gia_ManAppendCo( pNew, Abc_LitNotCond(iLitNew, Gia_ObjFaninC0(pObj)) );
449 }
450
451 // finish mapping
452 if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
453 Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
454 else
455 Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
456 assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
457 Vec_IntForEachEntry( vMapping, iLitNew, i )
458 if ( iLitNew > 0 )
459 Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
460 Vec_IntAppend( vMapping, vMapping2 );
461 Vec_IntFree( vMapping2 );
462 assert( pNew->vMapping == NULL );
463 pNew->vMapping = vMapping;
464
465 // create new timing manager and extra AIG
466 if ( pManTime )
467 pNew->pManTime = Gia_ManUpdateTimMan2( p, vBoxesLeft, 0 );
468 // update extra STG
469 if ( p->pAigExtra )
470 pNew->pAigExtra = Gia_ManUpdateExtraAig2( p->pManTime, p->pAigExtra, vBoxesLeft );
471 // duplicated flops
472 if ( p->vRegClasses )
473 pNew->vRegClasses = Vec_IntDup( p->vRegClasses );
474 // duplicated initial state
475 if ( p->vRegInits )
476 pNew->vRegInits = Vec_IntDup( p->vRegInits );
477 pNew->nAnd2Delay = p->nAnd2Delay;
478
479 // cleanup
480 Vec_WecFree( vGroups );
481 Vec_IntFree( vMfsTopo );
482 Vec_IntFree( vGroupMap );
483 Vec_IntFree( vMfs2Gia );
484 Vec_IntFree( vMfs2Old );
485 Vec_IntFree( vBoxesLeft );
486 return pNew;
487}
488
501{
502 Sfm_Ntk_t * pNtk;
503 Gia_Man_t * pNew;
504 int nFaninMax, nNodes;
505 assert( Gia_ManRegNum(p) == 0 );
506 assert( p->vMapping != NULL );
507 if ( p->pManTime != NULL && p->pAigExtra == NULL )
508 {
509 Abc_Print( 1, "Timing manager is given but there is no GIA of boxes.\n" );
510 return NULL;
511 }
512 if ( p->pManTime != NULL && p->pAigExtra != NULL && Gia_ManCiNum(p->pAigExtra) > 15 )
513 {
514 Abc_Print( 1, "Currently \"&mfs\" cannot process the network containing white-boxes with more than 15 inputs.\n" );
515 return NULL;
516 }
517 // count fanouts
518 nFaninMax = Gia_ManLutSizeMax( p );
519 if ( nFaninMax > 15 )
520 {
521 Abc_Print( 1, "Currently \"&mfs\" cannot process the network containing nodes with more than 15 fanins.\n" );
522 return NULL;
523 }
524 // collect information
525 pNtk = Gia_ManExtractMfs( p );
526 // perform optimization
527 nNodes = Sfm_NtkPerform( pNtk, pPars );
528 if ( nNodes == 0 )
529 {
530 if ( p->pManTime )
531 Abc_Print( 1, "The network is not changed by \"&mfs\".\n" );
532 pNew = Gia_ManDup( p );
533 pNew->vMapping = Vec_IntDup( p->vMapping );
534 Gia_ManTransferTiming( pNew, p );
535 }
536 else
537 {
538 pNew = Gia_ManInsertMfs( p, pNtk, pPars->fAllBoxes );
539 if( pPars->fVerbose )
540 Abc_Print( 1, "The network has %d nodes changed by \"&mfs\".\n", nNodes );
541 // check integrity
542 //Gia_ManCheckIntegrityWithBoxes( pNew );
543 }
544 Sfm_NtkFree( pNtk );
545 return pNew;
546}
547
551
553
int nWords
Definition abcNpn.c:127
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
#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
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Cube * p
Definition exorList.c:222
int Gia_ManFromIfLogicCreateLut(Gia_Man_t *pNew, word *pRes, Vec_Int_t *vLeaves, Vec_Int_t *vCover, Vec_Int_t *vMapping, Vec_Int_t *vMapping2)
Definition giaIf.c:1104
ABC_NAMESPACE_IMPL_START Sfm_Ntk_t * Gia_ManExtractMfs(Gia_Man_t *p)
DECLARATIONS ///.
Definition giaMfs.c:47
Gia_Man_t * Gia_ManInsertMfs(Gia_Man_t *p, Sfm_Ntk_t *pNtk, int fAllBoxes)
Definition giaMfs.c:285
Gia_Man_t * Gia_ManPerformMfs(Gia_Man_t *p, Sfm_Par_t *pPars)
Definition giaMfs.c:500
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition giaDup.c:720
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition giaTruth.c:628
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
int Gia_ManBoxNum(Gia_Man_t *p)
DECLARATIONS ///.
Definition giaTim.c:50
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void * Gia_ManUpdateTimMan2(Gia_Man_t *p, Vec_Int_t *vBoxesLeft, int nTermsDiff)
Definition giaTim.c:675
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition giaTruth.c:552
int Gia_ManLutSizeMax(Gia_Man_t *p)
Definition giaIf.c:127
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
Definition giaIf.c:2370
int Gia_ManLutNum(Gia_Man_t *p)
Definition giaIf.c:146
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition giaTruth.c:568
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
Gia_Man_t * Gia_ManUpdateExtraAig2(void *pTime, Gia_Man_t *pAig, Vec_Int_t *vBoxesLeft)
Definition giaTim.c:713
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int Sfm_NtkPerform(Sfm_Ntk_t *p, Sfm_Par_t *pPars)
Definition sfmCore.c:367
void Sfm_NtkFree(Sfm_Ntk_t *p)
Definition sfmNtk.c:219
struct Sfm_Par_t_ Sfm_Par_t
Definition sfm.h:42
typedefABC_NAMESPACE_HEADER_START struct Sfm_Ntk_t_ Sfm_Ntk_t
INCLUDES ///.
Definition sfm.h:41
Sfm_Ntk_t * Sfm_NtkConstruct(Vec_Wec_t *vFanins, int nPis, int nPos, Vec_Str_t *vFixed, Vec_Str_t *vEmpty, Vec_Wrd_t *vTruths, Vec_Int_t *vStarts, Vec_Wrd_t *vTruths2)
Definition sfmNtk.c:167
int Sfm_NodeReadUsed(Sfm_Ntk_t *p, int i)
Definition sfmNtk.c:382
word * Sfm_NodeReadTruth(Sfm_Ntk_t *p, int i)
Definition sfmNtk.c:374
Vec_Int_t * Sfm_NtkDfs(Sfm_Ntk_t *p, Vec_Wec_t *vGroups, Vec_Int_t *vGroupMap, Vec_Int_t *vBoxesLeft, int fAllBoxes)
Definition sfmWin.c:166
Vec_Int_t * Sfm_NodeReadFanins(Sfm_Ntk_t *p, int i)
Definition sfmNtk.c:370
Gia_Man_t * pAigExtra
Definition gia.h:167
int nAnd2Delay
Definition gia.h:202
char * pSpec
Definition gia.h:100
Vec_Int_t * vRegInits
Definition gia.h:161
Vec_Int_t * vMapping
Definition gia.h:136
Vec_Int_t * vRegClasses
Definition gia.h:160
void * pManTime
Definition gia.h:194
char * pName
Definition gia.h:99
int fAllBoxes
Definition sfm.h:71
int fVerbose
Definition sfm.h:74
int Tim_ManBoxIsBlack(Tim_Man_t *p, int iBox)
Definition timBox.c:258
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
Definition timBox.c:203
void Tim_ManBlackBoxIoNum(Tim_Man_t *p, int *pnBbIns, int *pnBbOuts)
Definition timMan.c:735
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
int Tim_ManPoNum(Tim_Man_t *p)
Definition timMan.c:714
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition timBox.c:187
int Tim_ManPiNum(Tim_Man_t *p)
Definition timMan.c:708
#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_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42