ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
acecFadds.c File Reference
#include "acecInt.h"
#include "misc/vec/vecWec.h"
#include "misc/tim/tim.h"
Include dependency graph for acecFadds.c:

Go to the source code of this file.

Macros

#define Dtc_ForEachCut(pList, pCut, i)
 DECLARATIONS ///.
 
#define Dtc_ForEachFadd(vFadds, i)
 

Functions

Vec_Int_tGia_ManDetectHalfAdders (Gia_Man_t *p, int fVerbose)
 FUNCTION DEFINITIONS ///.
 
void Gia_ManIllustrateBoxes (Gia_Man_t *p)
 
int Dtc_ManCutMergeOne (int *pCut0, int *pCut1, int *pCut)
 
int Dtc_ManCutCheckEqual (Vec_Int_t *vCuts, int *pCutNew)
 
int Dtc_ObjComputeTruth_rec (Gia_Obj_t *pObj)
 
void Dtc_ObjCleanTruth_rec (Gia_Obj_t *pObj)
 
int Dtc_ObjComputeTruth (Gia_Man_t *p, int iObj, int *pCut, int *pTruth)
 
void Dtc_ManCutMerge (Gia_Man_t *p, int iObj, int *pList0, int *pList1, Vec_Int_t *vCuts, Vec_Int_t *vCutsXor2, Vec_Int_t *vCutsXor, Vec_Int_t *vCutsMaj)
 
void Dtc_ManComputeCuts (Gia_Man_t *p, Vec_Int_t **pvCutsXor2, Vec_Int_t **pvCutsXor, Vec_Int_t **pvCutsMaj, int fVerbose)
 
Vec_Int_tDtc_ManFindCommonCuts (Gia_Man_t *p, Vec_Int_t *vCutsXor, Vec_Int_t *vCutsMaj)
 
void Dtc_ManPrintFadds (Vec_Int_t *vFadds)
 
int Dtc_ManCompare (int *pCut0, int *pCut1)
 
int Dtc_ManCompare2 (int *pCut0, int *pCut1)
 
Vec_Int_tGia_ManDetectFullAdders (Gia_Man_t *p, int fVerbose, Vec_Int_t **pvCutsXor2)
 
void Gia_ManDetectFullAdders2 (Gia_Man_t *p, int fVerbose)
 
Vec_Int_tGia_ManCreateMap (Gia_Man_t *p, Vec_Int_t *vFadds)
 
int Gia_ManFindChains_rec (Gia_Man_t *p, int iMaj, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Int_t *vLength)
 
void Gia_ManFindChains (Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap)
 
void Gia_ManCollectOneChain (Gia_Man_t *p, Vec_Int_t *vFadds, int iFaddTop, Vec_Int_t *vMap, Vec_Int_t *vChain)
 
void Gia_ManMarkWithTravId_rec (Gia_Man_t *p, int Id)
 
Vec_Wec_tGia_ManCollectTopmost (Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, int nFaddMin)
 
void Gia_ManPrintChains (Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains)
 
Vec_Int_tGia_ManFindMapping (Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains)
 
Vec_Int_tGia_ManCollectTruthTables (Gia_Man_t *p, Vec_Int_t *vFadds)
 
float * Gia_ManGenerateDelayTableFloat (int nIns, int nOuts)
 
Tim_Man_tGia_ManGenerateTim (int nPis, int nPos, int nBoxes, int nIns, int nOuts)
 
Gia_Man_tGia_ManGenerateExtraAig (int nBoxes, int nIns, int nOuts)
 
void Gia_ManDupFadd (Gia_Man_t *pNew, Gia_Man_t *p, Vec_Int_t *vChain, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains, Vec_Int_t *vMap2Chain, Vec_Int_t *vTruths)
 
void Gia_ManDupWithFaddBoxes_rec (Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains, Vec_Int_t *vMap2Chain, Vec_Int_t *vTruths)
 
Gia_Man_tGia_ManDupWithNaturalBoxes (Gia_Man_t *p, int nFaddMin, int fVerbose)
 
int Gia_ObjFanin0CopyCarry (Vec_Int_t *vCarries, Gia_Obj_t *pObj, int Id)
 
int Gia_ObjFanin1CopyCarry (Vec_Int_t *vCarries, Gia_Obj_t *pObj, int Id)
 
Gia_Man_tGia_ManDupWithArtificalFaddBoxes (Gia_Man_t *p, int fUseFanout, int fXorTrick)
 
Gia_Man_tGia_ManDupWithArtificalFaddBoxesTest (Gia_Man_t *p)
 
int Gia_ManFindAnnotatedDelay (Gia_Man_t *p, int DelayC, int *pnBoxes, int fIgnoreBoxDelays)
 
int Gia_ManFindChainStart (Gia_Man_t *p)
 
int Gia_ManFindPath (Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, Vec_Int_t *vPath)
 
int Gia_ManIteratePaths (Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fIgnoreBoxDelays, int fVerbose)
 
Gia_Man_tGia_ManDupWithArtificialBoxes (Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fUseFanout, int fXorTrick, int fIgnoreBoxDelays, int fVerbose)
 

Macro Definition Documentation

◆ Dtc_ForEachCut

#define Dtc_ForEachCut ( pList,
pCut,
i )
Value:
for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += pCut[0] + 1 )

DECLARATIONS ///.

CFile****************************************************************

FileName [acecFadds.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [CEC for arithmetic circuits.]

Synopsis [Detecting half-adders and full-adders.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
acecFadds.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 32 of file acecFadds.c.

◆ Dtc_ForEachFadd

#define Dtc_ForEachFadd ( vFadds,
i )
Value:
for ( i = 0; i < Vec_IntSize(vFadds)/5; i++ )

Definition at line 33 of file acecFadds.c.

Function Documentation

◆ Dtc_ManCompare()

int Dtc_ManCompare ( int * pCut0,
int * pCut1 )

Definition at line 425 of file acecFadds.c.

426{
427 if ( pCut0[0] < pCut1[0] ) return -1;
428 if ( pCut0[0] > pCut1[0] ) return 1;
429 if ( pCut0[1] < pCut1[1] ) return -1;
430 if ( pCut0[1] > pCut1[1] ) return 1;
431 if ( pCut0[2] < pCut1[2] ) return -1;
432 if ( pCut0[2] > pCut1[2] ) return 1;
433 return 0;
434}
Here is the caller graph for this function:

◆ Dtc_ManCompare2()

int Dtc_ManCompare2 ( int * pCut0,
int * pCut1 )

Definition at line 435 of file acecFadds.c.

436{
437 if ( pCut0[4] < pCut1[4] ) return -1;
438 if ( pCut0[4] > pCut1[4] ) return 1;
439 return 0;
440}
Here is the caller graph for this function:

◆ Dtc_ManComputeCuts()

void Dtc_ManComputeCuts ( Gia_Man_t * p,
Vec_Int_t ** pvCutsXor2,
Vec_Int_t ** pvCutsXor,
Vec_Int_t ** pvCutsMaj,
int fVerbose )

Definition at line 335 of file acecFadds.c.

336{
337 Gia_Obj_t * pObj;
338 int * pList0, * pList1, i, nCuts = 0;
339 Vec_Int_t * vTemp = Vec_IntAlloc( 1000 );
340 Vec_Int_t * vCutsXor2 = Vec_IntAlloc( Gia_ManAndNum(p) );
341 Vec_Int_t * vCutsXor = Vec_IntAlloc( Gia_ManAndNum(p) );
342 Vec_Int_t * vCutsMaj = Vec_IntAlloc( Gia_ManAndNum(p) );
343 Vec_Int_t * vCuts = Vec_IntAlloc( 30 * Gia_ManAndNum(p) );
344 Vec_IntFill( vCuts, Gia_ManObjNum(p), 0 );
346 Gia_ManForEachCi( p, pObj, i )
347 {
348 Vec_IntWriteEntry( vCuts, Gia_ObjId(p, pObj), Vec_IntSize(vCuts) );
349 Vec_IntPush( vCuts, 1 );
350 Vec_IntPush( vCuts, 1 );
351 Vec_IntPush( vCuts, Gia_ObjId(p, pObj) );
352 }
353 Gia_ManForEachAnd( p, pObj, i )
354 {
355 pList0 = Vec_IntEntryP( vCuts, Vec_IntEntry(vCuts, Gia_ObjFaninId0(pObj, i)) );
356 pList1 = Vec_IntEntryP( vCuts, Vec_IntEntry(vCuts, Gia_ObjFaninId1(pObj, i)) );
357 Dtc_ManCutMerge( p, i, pList0, pList1, vTemp, vCutsXor2, vCutsXor, vCutsMaj );
358 Vec_IntWriteEntry( vCuts, i, Vec_IntSize(vCuts) );
359 Vec_IntAppend( vCuts, vTemp );
360 nCuts += Vec_IntEntry( vTemp, 0 );
361 }
362 if ( fVerbose )
363 printf( "Nodes = %d. Cuts = %d. Cuts/Node = %.2f. Ints/Node = %.2f.\n",
364 Gia_ManAndNum(p), nCuts, 1.0*nCuts/Gia_ManAndNum(p), 1.0*Vec_IntSize(vCuts)/Gia_ManAndNum(p) );
365 Vec_IntFree( vTemp );
366 Vec_IntFree( vCuts );
367 if ( pvCutsXor2 )
368 *pvCutsXor2 = vCutsXor2;
369 else
370 Vec_IntFree( vCutsXor2 );
371 *pvCutsXor = vCutsXor;
372 *pvCutsMaj = vCutsMaj;
373}
void Dtc_ManCutMerge(Gia_Man_t *p, int iObj, int *pList0, int *pList1, Vec_Int_t *vCuts, Vec_Int_t *vCutsXor2, Vec_Int_t *vCutsXor, Vec_Int_t *vCutsMaj)
Definition acecFadds.c:272
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManCleanValue(Gia_Man_t *p)
Definition giaUtil.c:351
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dtc_ManCutCheckEqual()

int Dtc_ManCutCheckEqual ( Vec_Int_t * vCuts,
int * pCutNew )

Definition at line 217 of file acecFadds.c.

218{
219 int * pList = Vec_IntArray( vCuts );
220 int i, k, * pCut;
221 Dtc_ForEachCut( pList, pCut, i )
222 {
223 for ( k = 0; k <= pCut[0]; k++ )
224 if ( pCut[k] != pCutNew[k] )
225 break;
226 if ( k > pCut[0] )
227 return 1;
228 }
229 return 0;
230}
#define Dtc_ForEachCut(pList, pCut, i)
DECLARATIONS ///.
Definition acecFadds.c:32
Here is the caller graph for this function:

◆ Dtc_ManCutMerge()

void Dtc_ManCutMerge ( Gia_Man_t * p,
int iObj,
int * pList0,
int * pList1,
Vec_Int_t * vCuts,
Vec_Int_t * vCutsXor2,
Vec_Int_t * vCutsXor,
Vec_Int_t * vCutsMaj )

Definition at line 272 of file acecFadds.c.

273{
274 int fVerbose = 0;
275 Vec_Int_t * vTemp;
276 int i, k, c, Type, * pCut0, * pCut1, pCut[4];
277 if ( fVerbose )
278 printf( "Object %d = :\n", iObj );
279 Vec_IntFill( vCuts, 2, 1 );
280 Vec_IntPush( vCuts, iObj );
281 Dtc_ForEachCut( pList0, pCut0, i )
282 Dtc_ForEachCut( pList1, pCut1, k )
283 {
284 if ( !Dtc_ManCutMergeOne(pCut0, pCut1, pCut) )
285 continue;
286 if ( Dtc_ManCutCheckEqual(vCuts, pCut) )
287 continue;
288 Vec_IntAddToEntry( vCuts, 0, 1 );
289 if ( fVerbose )
290 printf( "%d : ", pCut[0] );
291 for ( c = 0; c <= pCut[0]; c++ )
292 {
293 Vec_IntPush( vCuts, pCut[c] );
294 if ( fVerbose && c )
295 printf( "%d ", pCut[c] );
296 }
297 if ( fVerbose )
298 printf( "\n" );
299 if ( pCut[0] == 2 )
300 {
301 int Value = Dtc_ObjComputeTruth( p, iObj, pCut, NULL );
302 assert( Value == 3 || Value == 0 );
303 if ( Value == 3 )
304 {
305 Vec_IntPush( vCutsXor2, pCut[1] );
306 Vec_IntPush( vCutsXor2, pCut[2] );
307 Vec_IntPush( vCutsXor2, iObj );
308 }
309 continue;
310 }
311 if ( pCut[0] != 3 )
312 continue;
313 Type = Dtc_ObjComputeTruth( p, iObj, pCut, NULL );
314 if ( Type == 0 )
315 continue;
316 vTemp = Type == 1 ? vCutsXor : vCutsMaj;
317 if ( 0 && Type == 2 )
318 {
319 fVerbose = 1;
320 if ( fVerbose )
321 printf( "%d = %s(", iObj, Type == 1 ? "XOR" : "MAJ" );
322 for ( c = 1; c <= pCut[0]; c++ )
323 {
324 if ( fVerbose )
325 printf( " %d", pCut[c] );
326 Vec_IntPush( vTemp, pCut[c] );
327 }
328 if ( fVerbose )
329 printf( " )\n" );
330 fVerbose = 0;
331 }
332 Vec_IntPush( vTemp, iObj );
333 }
334}
int Dtc_ObjComputeTruth(Gia_Man_t *p, int iObj, int *pCut, int *pTruth)
Definition acecFadds.c:254
int Dtc_ManCutCheckEqual(Vec_Int_t *vCuts, int *pCutNew)
Definition acecFadds.c:217
int Dtc_ManCutMergeOne(int *pCut0, int *pCut1, int *pCut)
Definition acecFadds.c:187
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dtc_ManCutMergeOne()

int Dtc_ManCutMergeOne ( int * pCut0,
int * pCut1,
int * pCut )

Function*************************************************************

Synopsis [Detecting FADDs in the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file acecFadds.c.

188{
189 int i, k;
190 for ( k = 0; k <= pCut1[0]; k++ )
191 pCut[k] = pCut1[k];
192 for ( i = 1; i <= pCut0[0]; i++ )
193 {
194 for ( k = 1; k <= pCut1[0]; k++ )
195 if ( pCut0[i] == pCut1[k] )
196 break;
197 if ( k <= pCut1[0] )
198 continue;
199 if ( pCut[0] == 3 )
200 return 0;
201 pCut[1+pCut[0]++] = pCut0[i];
202 }
203 assert( pCut[0] == 2 || pCut[0] == 3 );
204 if ( pCut[1] > pCut[2] )
205 ABC_SWAP( int, pCut[1], pCut[2] );
206 assert( pCut[1] < pCut[2] );
207 if ( pCut[0] == 2 )
208 return 1;
209 if ( pCut[2] > pCut[3] )
210 ABC_SWAP( int, pCut[2], pCut[3] );
211 if ( pCut[1] > pCut[2] )
212 ABC_SWAP( int, pCut[1], pCut[2] );
213 assert( pCut[1] < pCut[2] );
214 assert( pCut[2] < pCut[3] );
215 return 1;
216}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
Here is the caller graph for this function:

◆ Dtc_ManFindCommonCuts()

Vec_Int_t * Dtc_ManFindCommonCuts ( Gia_Man_t * p,
Vec_Int_t * vCutsXor,
Vec_Int_t * vCutsMaj )

Definition at line 374 of file acecFadds.c.

375{
376 int * pCuts0 = Vec_IntArray(vCutsXor);
377 int * pCuts1 = Vec_IntArray(vCutsMaj);
378 int * pLimit0 = Vec_IntLimit(vCutsXor);
379 int * pLimit1 = Vec_IntLimit(vCutsMaj); int i;
380 Vec_Int_t * vFadds = Vec_IntAlloc( 1000 );
381 assert( Vec_IntSize(vCutsXor) % 4 == 0 );
382 assert( Vec_IntSize(vCutsMaj) % 4 == 0 );
383 while ( pCuts0 < pLimit0 && pCuts1 < pLimit1 )
384 {
385 for ( i = 0; i < 3; i++ )
386 if ( pCuts0[i] != pCuts1[i] )
387 break;
388 if ( i == 3 )
389 {
390 for ( i = 0; i < 4; i++ )
391 Vec_IntPush( vFadds, pCuts0[i] );
392 Vec_IntPush( vFadds, pCuts1[3] );
393 pCuts0 += 4;
394 pCuts1 += 4;
395 }
396 else if ( pCuts0[i] < pCuts1[i] )
397 pCuts0 += 4;
398 else if ( pCuts0[i] > pCuts1[i] )
399 pCuts1 += 4;
400 }
401 assert( Vec_IntSize(vFadds) % 5 == 0 );
402 return vFadds;
403}
Here is the caller graph for this function:

◆ Dtc_ManPrintFadds()

void Dtc_ManPrintFadds ( Vec_Int_t * vFadds)

Definition at line 404 of file acecFadds.c.

405{
406 int i;
407 Dtc_ForEachFadd( vFadds, i )
408 {
409 printf( "%6d : ", i );
410 printf( "%6d ", Vec_IntEntry(vFadds, 5*i+0) );
411 printf( "%6d ", Vec_IntEntry(vFadds, 5*i+1) );
412 printf( "%6d ", Vec_IntEntry(vFadds, 5*i+2) );
413 printf( " -> " );
414 printf( "%6d ", Vec_IntEntry(vFadds, 5*i+3) );
415 printf( "%6d ", Vec_IntEntry(vFadds, 5*i+4) );
416 printf( "\n" );
417
418 if ( i == 100 )
419 {
420 printf( "Skipping other FADDs.\n" );
421 break;
422 }
423 }
424}
#define Dtc_ForEachFadd(vFadds, i)
Definition acecFadds.c:33
Here is the caller graph for this function:

◆ Dtc_ObjCleanTruth_rec()

void Dtc_ObjCleanTruth_rec ( Gia_Obj_t * pObj)

Definition at line 244 of file acecFadds.c.

245{
246 if ( !pObj->Value )
247 return;
248 pObj->Value = 0;
249 if ( !Gia_ObjIsAnd(pObj) )
250 return;
251 Dtc_ObjCleanTruth_rec( Gia_ObjFanin0(pObj) );
252 Dtc_ObjCleanTruth_rec( Gia_ObjFanin1(pObj) );
253}
void Dtc_ObjCleanTruth_rec(Gia_Obj_t *pObj)
Definition acecFadds.c:244
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dtc_ObjComputeTruth()

int Dtc_ObjComputeTruth ( Gia_Man_t * p,
int iObj,
int * pCut,
int * pTruth )

Definition at line 254 of file acecFadds.c.

255{
256 unsigned Truth, Truths[3] = { 0xAA, 0xCC, 0xF0 }; int i;
257 for ( i = 1; i <= pCut[0]; i++ )
258 Gia_ManObj(p, pCut[i])->Value = Truths[i-1];
259 Truth = 0xFF & Dtc_ObjComputeTruth_rec( Gia_ManObj(p, iObj) );
260 Dtc_ObjCleanTruth_rec( Gia_ManObj(p, iObj) );
261 if ( pTruth )
262 *pTruth = Truth;
263 if ( Truth == 0x66 || Truth == 0x99 )
264 return 3;
265 if ( Truth == 0x96 || Truth == 0x69 )
266 return 1;
267 if ( Truth == 0xE8 || Truth == 0xD4 || Truth == 0xB2 || Truth == 0x71 ||
268 Truth == 0x17 || Truth == 0x2B || Truth == 0x4D || Truth == 0x8E )
269 return 2;
270 return 0;
271}
int Dtc_ObjComputeTruth_rec(Gia_Obj_t *pObj)
Definition acecFadds.c:231
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dtc_ObjComputeTruth_rec()

int Dtc_ObjComputeTruth_rec ( Gia_Obj_t * pObj)

Definition at line 231 of file acecFadds.c.

232{
233 int Truth0, Truth1;
234 if ( pObj->Value )
235 return pObj->Value;
236 assert( Gia_ObjIsAnd(pObj) );
237 Truth0 = Dtc_ObjComputeTruth_rec( Gia_ObjFanin0(pObj) );
238 Truth1 = Dtc_ObjComputeTruth_rec( Gia_ObjFanin1(pObj) );
239 if ( Gia_ObjIsXor(pObj) )
240 return (pObj->Value = (Gia_ObjFaninC0(pObj) ? ~Truth0 : Truth0) ^ (Gia_ObjFaninC1(pObj) ? ~Truth1 : Truth1));
241 else
242 return (pObj->Value = (Gia_ObjFaninC0(pObj) ? ~Truth0 : Truth0) & (Gia_ObjFaninC1(pObj) ? ~Truth1 : Truth1));
243}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCollectOneChain()

void Gia_ManCollectOneChain ( Gia_Man_t * p,
Vec_Int_t * vFadds,
int iFaddTop,
Vec_Int_t * vMap,
Vec_Int_t * vChain )

Definition at line 530 of file acecFadds.c.

531{
532 int iFadd;
533 Vec_IntClear( vChain );
534 for ( iFadd = iFaddTop; iFadd >= 0 &&
535 !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+3)) &&
536 !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+4));
537 iFadd = Vec_IntEntry(vMap, Vec_IntEntry(vFadds, 5*iFadd+0)) )
538 {
539 Vec_IntPush( vChain, iFadd );
540 }
541 Vec_IntReverseOrder( vChain );
542}
Here is the caller graph for this function:

◆ Gia_ManCollectTopmost()

Vec_Wec_t * Gia_ManCollectTopmost ( Gia_Man_t * p,
Vec_Int_t * vFadds,
Vec_Int_t * vMap,
int nFaddMin )

Definition at line 556 of file acecFadds.c.

557{
558 int i, j, iFadd;
559 Vec_Int_t * vChain = Vec_IntAlloc( 100 );
560 Vec_Wec_t * vChains = Vec_WecAlloc( Vec_IntSize(vFadds)/5 );
561 // erase elements appearing as FADD inputs
562 Vec_Bit_t * vMarksTop = Vec_BitStart( Vec_IntSize(vFadds)/5 );
563 Dtc_ForEachFadd( vFadds, i )
564 if ( (iFadd = Vec_IntEntry(vMap, Vec_IntEntry(vFadds, 5*i+0))) >= 0 )
565 Vec_BitWriteEntry( vMarksTop, iFadd, 1 );
566 // compress the remaining ones
568 Dtc_ForEachFadd( vFadds, i )
569 {
570 if ( Vec_BitEntry(vMarksTop, i) )
571 continue;
572 Gia_ManCollectOneChain( p, vFadds, i, vMap, vChain );
573 if ( Vec_IntSize(vChain) < nFaddMin )
574 continue;
575 Vec_IntAppend( Vec_WecPushLevel(vChains), vChain );
576 Vec_IntForEachEntry( vChain, iFadd, j )
577 {
578 assert( !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+3)) );
579 assert( !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+4)) );
580 Gia_ManMarkWithTravId_rec( p, Vec_IntEntry(vFadds, 5*iFadd+3) );
581 Gia_ManMarkWithTravId_rec( p, Vec_IntEntry(vFadds, 5*iFadd+4) );
582 }
583 }
584 // cleanup
585 Vec_BitFree( vMarksTop );
586 Vec_IntFree( vChain );
587 return vChains;
588}
void Gia_ManCollectOneChain(Gia_Man_t *p, Vec_Int_t *vFadds, int iFaddTop, Vec_Int_t *vMap, Vec_Int_t *vChain)
Definition acecFadds.c:530
void Gia_ManMarkWithTravId_rec(Gia_Man_t *p, int Id)
Definition acecFadds.c:543
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
#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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCollectTruthTables()

Vec_Int_t * Gia_ManCollectTruthTables ( Gia_Man_t * p,
Vec_Int_t * vFadds )

Function*************************************************************

Synopsis [Derive GIA with boxes containing adder-chains.]

Description []

SideEffects []

SeeAlso []

Definition at line 652 of file acecFadds.c.

653{
654 int i, k, Type, Truth, pCut[4] = {3};
655 Vec_Int_t * vTruths = Vec_IntAlloc( 2*Vec_IntSize(vFadds)/5 );
657 Dtc_ForEachFadd( vFadds, i )
658 {
659 for ( k = 0; k < 3; k++ )
660 pCut[k+1] = Vec_IntEntry( vFadds, 5*i+k );
661 Type = Dtc_ObjComputeTruth( p, Vec_IntEntry(vFadds, 5*i+3), pCut, &Truth );
662 assert( Type == 1 );
663 Vec_IntPush( vTruths, Truth );
664 Type = Dtc_ObjComputeTruth( p, Vec_IntEntry(vFadds, 5*i+4), pCut, &Truth );
665 assert( Type == 2 );
666 Vec_IntPush( vTruths, Truth );
667 }
668 return vTruths;
669}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCreateMap()

Vec_Int_t * Gia_ManCreateMap ( Gia_Man_t * p,
Vec_Int_t * vFadds )

Function*************************************************************

Synopsis [Map each MAJ into the topmost MAJ of its chain.]

Description []

SideEffects []

SeeAlso []

Definition at line 481 of file acecFadds.c.

482{
483 Vec_Int_t * vMap = Vec_IntStartFull( Gia_ManObjNum(p) ); int i;
484 Dtc_ForEachFadd( vFadds, i )
485 Vec_IntWriteEntry( vMap, Vec_IntEntry(vFadds, 5*i+4), i );
486 return vMap;
487}
Here is the caller graph for this function:

◆ Gia_ManDetectFullAdders()

Vec_Int_t * Gia_ManDetectFullAdders ( Gia_Man_t * p,
int fVerbose,
Vec_Int_t ** pvCutsXor2 )

Definition at line 442 of file acecFadds.c.

443{
444 Vec_Int_t * vCutsXor, * vCutsMaj, * vFadds;
445 Dtc_ManComputeCuts( p, pvCutsXor2, &vCutsXor, &vCutsMaj, fVerbose );
446 qsort( Vec_IntArray(vCutsXor), (size_t)(Vec_IntSize(vCutsXor)/4), 16, (int (*)(const void *, const void *))Dtc_ManCompare );
447 qsort( Vec_IntArray(vCutsMaj), (size_t)(Vec_IntSize(vCutsMaj)/4), 16, (int (*)(const void *, const void *))Dtc_ManCompare );
448 vFadds = Dtc_ManFindCommonCuts( p, vCutsXor, vCutsMaj );
449 qsort( Vec_IntArray(vFadds), (size_t)(Vec_IntSize(vFadds)/5), 20, (int (*)(const void *, const void *))Dtc_ManCompare2 );
450 if ( fVerbose )
451 printf( "XOR3 cuts = %d. MAJ cuts = %d. Full-adders = %d.\n", Vec_IntSize(vCutsXor)/4, Vec_IntSize(vCutsMaj)/4, Vec_IntSize(vFadds)/5 );
452 if ( fVerbose )
453 Dtc_ManPrintFadds( vFadds );
454 Vec_IntFree( vCutsXor );
455 Vec_IntFree( vCutsMaj );
456 return vFadds;
457}
void Dtc_ManComputeCuts(Gia_Man_t *p, Vec_Int_t **pvCutsXor2, Vec_Int_t **pvCutsXor, Vec_Int_t **pvCutsMaj, int fVerbose)
Definition acecFadds.c:335
int Dtc_ManCompare(int *pCut0, int *pCut1)
Definition acecFadds.c:425
Vec_Int_t * Dtc_ManFindCommonCuts(Gia_Man_t *p, Vec_Int_t *vCutsXor, Vec_Int_t *vCutsMaj)
Definition acecFadds.c:374
void Dtc_ManPrintFadds(Vec_Int_t *vFadds)
Definition acecFadds.c:404
int Dtc_ManCompare2(int *pCut0, int *pCut1)
Definition acecFadds.c:435
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDetectFullAdders2()

void Gia_ManDetectFullAdders2 ( Gia_Man_t * p,
int fVerbose )

Definition at line 458 of file acecFadds.c.

459{
460 Vec_Int_t * vCutsXor2, * vCutsXor, * vCutsMaj;
461 Dtc_ManComputeCuts( p, &vCutsXor2, &vCutsXor, &vCutsMaj, fVerbose );
462 if ( fVerbose )
463 printf( "XOR3 cuts = %d. MAJ cuts = %d.\n", Vec_IntSize(vCutsXor)/4, Vec_IntSize(vCutsMaj)/4 );
464 Vec_IntFree( vCutsXor2 );
465 Vec_IntFree( vCutsXor );
466 Vec_IntFree( vCutsMaj );
467}
Here is the call graph for this function:

◆ Gia_ManDetectHalfAdders()

Vec_Int_t * Gia_ManDetectHalfAdders ( Gia_Man_t * p,
int fVerbose )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Detecting HADDs in the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file acecFadds.c.

51{
52 Vec_Int_t * vHadds = Vec_IntAlloc( 1000 );
53 Gia_Obj_t * pObj, * pFan0, * pFan1;
54 int i, iLit, iFan0, iFan1, fComplDiff, Count, Counts[5] = {0};
56 if ( p->nXors )
57 {
58 Gia_ManForEachAnd( p, pObj, i )
59 {
60 if ( !Gia_ObjIsXor(pObj) )
61 continue;
62 Count = 0;
63 iFan0 = Gia_ObjFaninId0(pObj, i);
64 iFan1 = Gia_ObjFaninId1(pObj, i);
65 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 0), Abc_Var2Lit(iFan1, 0))) )
66 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
67 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 1), Abc_Var2Lit(iFan1, 1))) )
68 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
69 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 0), Abc_Var2Lit(iFan1, 1))) )
70 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
71 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 1), Abc_Var2Lit(iFan1, 0))) )
72 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
73 Counts[Count]++;
74 }
75 }
76 else
77 {
78 ABC_FREE( p->pRefs );
80 Gia_ManForEachAnd( p, pObj, i )
81 {
82 if ( !Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
83 continue;
84 Count = 0;
85 if ( Gia_ObjRefNumId(p, Gia_ObjFaninId0(pObj, i)) > 1 )
86 Vec_IntPushTwo( vHadds, i, Gia_ObjFaninId0(pObj, i) ), Count++;
87 if ( Gia_ObjRefNumId(p, Gia_ObjFaninId1(pObj, i)) > 1 )
88 Vec_IntPushTwo( vHadds, i, Gia_ObjFaninId1(pObj, i) ), Count++;
89 iFan0 = Gia_ObjId( p, pFan0 );
90 iFan1 = Gia_ObjId( p, pFan1 );
91 fComplDiff = (Gia_ObjFaninC0(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC1(Gia_ObjFanin0(pObj)));
92 assert( fComplDiff == (Gia_ObjFaninC0(Gia_ObjFanin1(pObj)) ^ Gia_ObjFaninC1(Gia_ObjFanin1(pObj))) );
93 if ( fComplDiff )
94 {
95 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 0), Abc_Var2Lit(iFan1, 0))) )
96 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
97 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 1), Abc_Var2Lit(iFan1, 1))) )
98 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
99 }
100 else
101 {
102 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 0), Abc_Var2Lit(iFan1, 1))) )
103 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
104 if ( (iLit = Gia_ManHashLookupInt(p, Abc_Var2Lit(iFan0, 1), Abc_Var2Lit(iFan1, 0))) )
105 Vec_IntPushTwo( vHadds, i, Abc_Lit2Var(iLit) ), Count++;
106 }
107 Counts[Count]++;
108 }
109 ABC_FREE( p->pRefs );
110 }
112 if ( fVerbose )
113 {
114 int iXor, iAnd;
115 printf( "Found %d half-adders with XOR gates: ", Vec_IntSize(vHadds)/2 );
116 for ( i = 0; i <= 4; i++ )
117 printf( "%d=%d ", i, Counts[i] );
118 printf( "\n" );
119
120 Vec_IntForEachEntryDouble( vHadds, iXor, iAnd, i )
121 {
122 pObj = Gia_ManObj( p, iXor );
123 printf( "%3d : %5d %5d -> %5d %5d\n", i, Gia_ObjFaninId0(pObj, iXor), Gia_ObjFaninId1(pObj, iXor), iXor, iAnd );
124 }
125 }
126 return vHadds;
127}
#define ABC_FREE(obj)
Definition abc_global.h:267
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
int Gia_ObjRecognizeExor(Gia_Obj_t *pObj, Gia_Obj_t **ppFan0, Gia_Obj_t **ppFan1)
Definition giaUtil.c:1018
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition giaUtil.c:779
int Gia_ManHashLookupInt(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:81
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDupFadd()

void Gia_ManDupFadd ( Gia_Man_t * pNew,
Gia_Man_t * p,
Vec_Int_t * vChain,
Vec_Int_t * vFadds,
Vec_Int_t * vMap,
Vec_Wec_t * vChains,
Vec_Int_t * vMap2Chain,
Vec_Int_t * vTruths )

Definition at line 718 of file acecFadds.c.

719{
720 extern void Gia_ManDupWithFaddBoxes_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Wec_t * vChains, Vec_Int_t * vMap2Chain, Vec_Int_t * vTruths );
721 int i, k, iFadd = -1, iCiLit, pLits[3];
722 Gia_Obj_t * pObj;
723 // construct FADD inputs
724 Vec_IntForEachEntry( vChain, iFadd, i )
725 for ( k = 0; k < 3; k++ )
726 {
727 if ( i && !k ) continue;
728 pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+k) );
729 Gia_ManDupWithFaddBoxes_rec( pNew, p, pObj, vFadds, vMap, vChains, vMap2Chain, vTruths );
730 }
731 // construct boxes
732 iCiLit = 0;
733 Vec_IntForEachEntry( vChain, iFadd, i )
734 {
735 int iXorTruth = Vec_IntEntry( vTruths, 2*iFadd+0 );
736 int iMajTruth = Vec_IntEntry( vTruths, 2*iFadd+1 );
737 for ( k = 0; k < 3; k++ )
738 {
739 pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+k) );
740 pLits[k] = (!k && iCiLit) ? iCiLit : pObj->Value;
741 assert( pLits[k] >= 0 );
742 }
743 // normalize truth table
744 // if ( Truth == 0xE8 || Truth == 0xD4 || Truth == 0xB2 || Truth == 0x71 ||
745 // Truth == 0x17 || Truth == 0x2B || Truth == 0x4D || Truth == 0x8E )
746 if ( iMajTruth == 0x4D )
747 pLits[0] = Abc_LitNot(pLits[0]), iMajTruth = 0x8E, iXorTruth = 0xFF & ~iXorTruth;
748 else if ( iMajTruth == 0xD4 )
749 pLits[0] = Abc_LitNot(pLits[0]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
750 else if ( iMajTruth == 0x2B )
751 pLits[1] = Abc_LitNot(pLits[1]), iMajTruth = 0x8E, iXorTruth = 0xFF & ~iXorTruth;
752 else if ( iMajTruth == 0xB2 )
753 pLits[1] = Abc_LitNot(pLits[1]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
754 if ( iMajTruth == 0x8E )
755 pLits[2] = Abc_LitNot(pLits[2]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
756 else if ( iMajTruth == 0x71 )
757 pLits[2] = Abc_LitNot(pLits[2]), iMajTruth = 0x17, iXorTruth = 0xFF & ~iXorTruth;
758 else assert( iMajTruth == 0xE8 || iMajTruth == 0x17 );
759 // normalize carry-in
760 if ( Abc_LitIsCompl(pLits[0]) )
761 {
762 for ( k = 0; k < 3; k++ )
763 pLits[k] = Abc_LitNot(pLits[k]);
764 iXorTruth = 0xFF & ~iXorTruth;
765 iMajTruth = 0xFF & ~iMajTruth;
766 }
767 // add COs
768 assert( !Abc_LitIsCompl(pLits[0]) );
769 for ( k = 0; k < 3; k++ )
770 Gia_ManAppendCo( pNew, pLits[k] );
771 // create CI
772 assert( iXorTruth == 0x96 || iXorTruth == 0x69 );
773 pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+3) );
774 pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), (int)(iXorTruth == 0x69) );
775 // create CI
776 assert( iMajTruth == 0xE8 || iMajTruth == 0x17 );
777 iCiLit = Abc_LitNotCond( Gia_ManAppendCi(pNew), (int)(iMajTruth == 0x17) );
778 }
779 // assign carry out
780 assert( iFadd == Vec_IntEntryLast(vChain) );
781 pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+4) );
782 pObj->Value = iCiLit;
783}
void Gia_ManDupWithFaddBoxes_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains, Vec_Int_t *vMap2Chain, Vec_Int_t *vTruths)
Definition acecFadds.c:784
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDupWithArtificalFaddBoxes()

Gia_Man_t * Gia_ManDupWithArtificalFaddBoxes ( Gia_Man_t * p,
int fUseFanout,
int fXorTrick )

Definition at line 921 of file acecFadds.c.

922{
923 Gia_Man_t * pNew;
924 Gia_Obj_t * pObj;
925 int nBoxes = Gia_ManBoxNum(p);
926 int i, nRealPis, nRealPos;
927 Vec_Int_t * vCarries = NULL;
928 // make sure two chains do not overlap
930 Gia_ManForEachCi( p, pObj, i )
931 assert( !pObj->fMark0 && !pObj->fMark1 );
932 Gia_ManForEachCo( p, pObj, i )
933 assert( !pObj->fMark0 && !pObj->fMark1 );
934 Gia_ManForEachAnd( p, pObj, i )
935 {
936 assert( !pObj->fMark0 || !pObj->fMark1 );
937 if ( pObj->fMark0 )
938 {
939 assert( Gia_ObjFanin0(pObj)->fPhase == 0 );
940 Gia_ObjFanin0(pObj)->fPhase = 1;
941 }
942 if ( pObj->fMark1 )
943 {
944 assert( Gia_ObjFanin1(pObj)->fPhase == 0 );
945 Gia_ObjFanin1(pObj)->fPhase = 1;
946 }
947 }
948 // create mapping for carry-chains
949 if ( !fUseFanout )
950 vCarries = Vec_IntStartFull( Gia_ManObjNum(p) );
951 // create references and discount carries
952 if ( vCarries )
953 {
955 Gia_ManForEachAnd( p, pObj, i )
956 if ( pObj->fMark0 )
957 Gia_ObjRefFanin0Dec( p, pObj );
958 else if ( pObj->fMark1 )
959 Gia_ObjRefFanin1Dec( p, pObj );
960 }
961 // if AIG already has (natural) FADD boxes, it should not un-normalized
963 pNew = Gia_ManStart( Gia_ManObjNum(p) );
964 pNew->pName = Abc_UtilStrsav( p->pName );
965 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
966 Gia_ManConst0(p)->Value = 0;
967 Gia_ManForEachObj1( p, pObj, i )
968 {
969 if ( Gia_ObjIsCi(pObj) )
970 pObj->Value = Gia_ManAppendCi( pNew );
971 else if ( Gia_ObjIsCo(pObj) )
972 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
973 else if ( !pObj->fMark0 && !pObj->fMark1 ) // AND-gate
974 pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
975 else // AND-gate with chain
976 {
977 int iCiLit, iOtherLit, iLit0, iLit1, iLit2, iXorLit;
978 assert( pObj->fMark0 != pObj->fMark1 );
979 iCiLit = pObj->fMark0 ? Gia_ObjFanin0CopyCarry(vCarries, pObj, i) : Gia_ObjFanin1CopyCarry(vCarries, pObj, i);
980 iOtherLit = pObj->fMark0 ? Gia_ObjFanin1Copy(pObj) : Gia_ObjFanin0Copy(pObj);
981 assert( iCiLit >= 0 && iOtherLit >= 0 );
982 iLit0 = Abc_LitNotCond( iCiLit, Abc_LitIsCompl(iCiLit) );
983 iLit1 = Abc_LitNotCond( iOtherLit, Abc_LitIsCompl(iCiLit) );
984 iLit2 = Abc_LitNotCond( 0, Abc_LitIsCompl(iCiLit) );
985 // add COs
986 assert( !Abc_LitIsCompl(iLit0) );
987 Gia_ManAppendCo( pNew, iLit0 );
988 Gia_ManAppendCo( pNew, iLit1 );
989 Gia_ManAppendCo( pNew, iLit2 );
990 // add CI (unused sum bit)
991 iXorLit = Gia_ManAppendCi(pNew);
992 // add CI (carry bit)
993 pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), Abc_LitIsCompl(iCiLit) );
994 if ( vCarries && pObj->fPhase )
995 {
996 Vec_IntWriteEntry( vCarries, i, pObj->Value );
997 if ( Gia_ObjRefNum(p, pObj) > 0 )
998 {
999 if ( fXorTrick )
1000 pObj->Value = Gia_ManAppendAnd( pNew, Abc_LitNotCond(iXorLit, !Abc_LitIsCompl(iCiLit)), iOtherLit );
1001 else
1002 pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1003 }
1004 }
1005 nBoxes++;
1006 }
1007 }
1009 Vec_IntFreeP( &vCarries );
1010 ABC_FREE( p->pRefs );
1011 assert( !Gia_ManHasDangling(pNew) );
1012 // other information
1013// nBoxes += (Gia_ManCiNum(pNew) - Gia_ManCiNum(p)) / 2;
1014// assert( nBoxes == Gia_ManBoxNum(p) + (Gia_ManCoNum(pNew) - Gia_ManCoNum(p)) / 3 );
1015 nRealPis = Gia_ManBoxNum(p) ? Tim_ManPiNum((Tim_Man_t *)p->pManTime) : Gia_ManCiNum(p);
1016 nRealPos = Gia_ManBoxNum(p) ? Tim_ManPoNum((Tim_Man_t *)p->pManTime) : Gia_ManCoNum(p);
1017 pNew->pManTime = Gia_ManGenerateTim( nRealPis, nRealPos, nBoxes, 3, 2 );
1018 pNew->pAigExtra = Gia_ManGenerateExtraAig( nBoxes, 3, 2 );
1019 // optionally normalize the AIG
1020 return pNew;
1021}
int Gia_ObjFanin0CopyCarry(Vec_Int_t *vCarries, Gia_Obj_t *pObj, int Id)
Definition acecFadds.c:909
int Gia_ObjFanin1CopyCarry(Vec_Int_t *vCarries, Gia_Obj_t *pObj, int Id)
Definition acecFadds.c:915
Gia_Man_t * Gia_ManGenerateExtraAig(int nBoxes, int nIns, int nOuts)
Definition acecFadds.c:704
Tim_Man_t * Gia_ManGenerateTim(int nPis, int nPos, int nBoxes, int nIns, int nOuts)
Definition acecFadds.c:682
int Gia_ManHasDangling(Gia_Man_t *p)
Definition giaUtil.c:1353
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
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
void Gia_ManCleanPhase(Gia_Man_t *p)
Definition giaUtil.c:472
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
Gia_Man_t * pAigExtra
Definition gia.h:167
char * pSpec
Definition gia.h:100
void * pManTime
Definition gia.h:194
char * pName
Definition gia.h:99
unsigned fMark1
Definition gia.h:86
unsigned fPhase
Definition gia.h:87
unsigned fMark0
Definition gia.h:81
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_ManPiNum(Tim_Man_t *p)
Definition timMan.c:708
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDupWithArtificalFaddBoxesTest()

Gia_Man_t * Gia_ManDupWithArtificalFaddBoxesTest ( Gia_Man_t * p)

Definition at line 1022 of file acecFadds.c.

1023{
1024 Gia_Man_t * pNew;
1025 Gia_Obj_t * pObj;
1026 int i;
1027 // label some and-gates
1029 Gia_ManForEachAnd( p, pObj, i )
1030 {
1031 pObj->fMark0 = i % 5;
1032 pObj->fMark1 = i % 7;
1033 if ( pObj->fMark0 && pObj->fMark1 )
1034 pObj->fMark0 = pObj->fMark1 = 0;
1035 }
1036
1037 // output new AIG
1038 pNew = Gia_ManDupWithArtificalFaddBoxes( p, 0, 0 );
1040 return pNew;
1041}
Gia_Man_t * Gia_ManDupWithArtificalFaddBoxes(Gia_Man_t *p, int fUseFanout, int fXorTrick)
Definition acecFadds.c:921
void Gia_ManCleanMark01(Gia_Man_t *p)
Definition giaUtil.c:218
Here is the call graph for this function:

◆ Gia_ManDupWithArtificialBoxes()

Gia_Man_t * Gia_ManDupWithArtificialBoxes ( Gia_Man_t * p,
int DelayC,
int nPathMin,
int nPathMax,
int nPathLimit,
int fUseFanout,
int fXorTrick,
int fIgnoreBoxDelays,
int fVerbose )

Definition at line 1240 of file acecFadds.c.

1241{
1242 Gia_Man_t * pNew;
1243/*
1244 if ( Gia_ManBoxNum(p) > 0 )
1245 {
1246 printf( "Currently artifical carry-chains cannot be detected when natural ones are present.\n" );
1247 return NULL;
1248 }
1249*/
1250 Gia_ManIteratePaths( p, DelayC, nPathMin, nPathMax, nPathLimit, fIgnoreBoxDelays, fVerbose );
1251 pNew = Gia_ManDupWithArtificalFaddBoxes( p, fUseFanout, fXorTrick );
1253 return pNew;
1254}
int Gia_ManIteratePaths(Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fIgnoreBoxDelays, int fVerbose)
Definition acecFadds.c:1211
Here is the call graph for this function:

◆ Gia_ManDupWithFaddBoxes_rec()

void Gia_ManDupWithFaddBoxes_rec ( Gia_Man_t * pNew,
Gia_Man_t * p,
Gia_Obj_t * pObj,
Vec_Int_t * vFadds,
Vec_Int_t * vMap,
Vec_Wec_t * vChains,
Vec_Int_t * vMap2Chain,
Vec_Int_t * vTruths )

Definition at line 784 of file acecFadds.c.

785{
786 int iChain;
787 if ( ~pObj->Value )
788 return;
789 assert( Gia_ObjIsAnd(pObj) );
790 iChain = Vec_IntEntry( vMap2Chain, Gia_ObjId(p, pObj) );
791/*
792 assert( iChain == -1 );
793 if ( iChain >= 0 )
794 {
795 Gia_ManDupFadd( pNew, p, Vec_WecEntry(vChains, iChain), vFadds, vMap, vChains, vMap2Chain, vTruths );
796 assert( ~pObj->Value );
797 return;
798 }
799*/
800 Gia_ManDupWithFaddBoxes_rec( pNew, p, Gia_ObjFanin0(pObj), vFadds, vMap, vChains, vMap2Chain, vTruths );
801 Gia_ManDupWithFaddBoxes_rec( pNew, p, Gia_ObjFanin1(pObj), vFadds, vMap, vChains, vMap2Chain, vTruths );
802 pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
803}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDupWithNaturalBoxes()

Gia_Man_t * Gia_ManDupWithNaturalBoxes ( Gia_Man_t * p,
int nFaddMin,
int fVerbose )

Definition at line 804 of file acecFadds.c.

805{
806 abctime clk = Abc_Clock();
807 Gia_Man_t * pNew;//, * pTemp;
808 Vec_Int_t * vFadds, * vMap, * vMap2Chain, * vTruths, * vChain;
809 Vec_Wec_t * vChains;
810 Gia_Obj_t * pObj;
811 int i, nBoxes;
812 if ( Gia_ManBoxNum(p) > 0 )
813 {
814 printf( "Currently natural carry-chains cannot be detected when boxes are present.\n" );
815 return NULL;
816 }
817 assert( Gia_ManBoxNum(p) == 0 );
818
819 // detect FADDs
820 vFadds = Gia_ManDetectFullAdders( p, fVerbose, NULL );
821 assert( Vec_IntSize(vFadds) % 5 == 0 );
822 // map MAJ into its FADD
823 vMap = Gia_ManCreateMap( p, vFadds );
824 // for each FADD, find the longest chain and reorder its inputs
825 Gia_ManFindChains( p, vFadds, vMap );
826 // returns the set of topmost MAJ nodes
827 vChains = Gia_ManCollectTopmost( p, vFadds, vMap, nFaddMin );
828 if ( fVerbose )
829 Gia_ManPrintChains( p, vFadds, vMap, vChains );
830 if ( Vec_WecSize(vChains) == 0 )
831 {
832 Vec_IntFree( vFadds );
833 Vec_IntFree( vMap );
834 Vec_WecFree( vChains );
835 return Gia_ManDup( p );
836 }
837 // returns mapping of each MAJ into the topmost elements of its chain
838 vMap2Chain = Gia_ManFindMapping( p, vFadds, vMap, vChains );
839 // compute truth tables for FADDs
840 vTruths = Gia_ManCollectTruthTables( p, vFadds );
841 if ( fVerbose )
842 Abc_PrintTime( 1, "Carry-chain detection time", Abc_Clock() - clk );
843
844 // duplicate
845 clk = Abc_Clock();
847 pNew = Gia_ManStart( Gia_ManObjNum(p) );
848 pNew->pName = Abc_UtilStrsav( p->pName );
849 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
850 Gia_ManConst0(p)->Value = 0;
851 Gia_ManForEachCi( p, pObj, i )
852 pObj->Value = Gia_ManAppendCi( pNew );
853 Vec_WecForEachLevel( vChains, vChain, i )
854 Gia_ManDupFadd( pNew, p, vChain, vFadds, vMap, vChains, vMap2Chain, vTruths );
855 Gia_ManForEachCo( p, pObj, i )
856 Gia_ManDupWithFaddBoxes_rec( pNew, p, Gia_ObjFanin0(pObj), vFadds, vMap, vChains, vMap2Chain, vTruths );
857 Gia_ManForEachCo( p, pObj, i )
858 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
859 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
860 if ( Gia_ManRegNum(p) )
861 {
862 if ( fVerbose )
863 printf( "Warning: Sequential design is converted into combinational one by adding white boxes.\n" );
864 pNew->nRegs = 0;
865 }
866 assert( !Gia_ManHasDangling(pNew) );
867
868 // cleanup
869 Vec_IntFree( vFadds );
870 Vec_IntFree( vMap );
871 Vec_WecFree( vChains );
872 Vec_IntFree( vMap2Chain );
873 Vec_IntFree( vTruths );
874
875 // other information
876 nBoxes = (Gia_ManCiNum(pNew) - Gia_ManCiNum(p)) / 2;
877 assert( nBoxes == (Gia_ManCoNum(pNew) - Gia_ManCoNum(p)) / 3 );
878 pNew->pManTime = Gia_ManGenerateTim( Gia_ManCiNum(p), Gia_ManCoNum(p), nBoxes, 3, 2 );
879 pNew->pAigExtra = Gia_ManGenerateExtraAig( nBoxes, 3, 2 );
880/*
881 // normalize
882 pNew = Gia_ManDupNormalize( pTemp = pNew, 0 );
883 pNew->pManTime = pTemp->pManTime; pTemp->pManTime = NULL;
884 pNew->pAigExtra = pTemp->pAigExtra; pTemp->pAigExtra = NULL;
885 Gia_ManStop( pTemp );
886*/
887 //pNew = Gia_ManDupCollapse( pTemp = pNew, pNew->pAigExtra, NULL );
888 //Gia_ManStop( pTemp );
889
890 //Gia_ManIllustrateBoxes( pNew );
891 if ( fVerbose )
892 Abc_PrintTime( 1, "AIG with boxes construction time", Abc_Clock() - clk );
893 return pNew;
894}
ABC_INT64_T abctime
Definition abc_global.h:332
Vec_Int_t * Gia_ManCreateMap(Gia_Man_t *p, Vec_Int_t *vFadds)
Definition acecFadds.c:481
void Gia_ManPrintChains(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains)
Definition acecFadds.c:590
Vec_Int_t * Gia_ManDetectFullAdders(Gia_Man_t *p, int fVerbose, Vec_Int_t **pvCutsXor2)
Definition acecFadds.c:442
void Gia_ManDupFadd(Gia_Man_t *pNew, Gia_Man_t *p, Vec_Int_t *vChain, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains, Vec_Int_t *vMap2Chain, Vec_Int_t *vTruths)
Definition acecFadds.c:718
void Gia_ManFindChains(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap)
Definition acecFadds.c:520
Vec_Int_t * Gia_ManCollectTruthTables(Gia_Man_t *p, Vec_Int_t *vFadds)
Definition acecFadds.c:652
Vec_Int_t * Gia_ManFindMapping(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Wec_t *vChains)
Definition acecFadds.c:620
Vec_Wec_t * Gia_ManCollectTopmost(Gia_Man_t *p, Vec_Int_t *vFadds, Vec_Int_t *vMap, int nFaddMin)
Definition acecFadds.c:556
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition giaDup.c:720
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
int nRegs
Definition gia.h:101
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:

◆ Gia_ManFindAnnotatedDelay()

int Gia_ManFindAnnotatedDelay ( Gia_Man_t * p,
int DelayC,
int * pnBoxes,
int fIgnoreBoxDelays )

Function*************************************************************

Synopsis [Adds artificial carry chains to the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1055 of file acecFadds.c.

1056{
1057 Gia_Obj_t * pObj;
1058 int nRealPis = Gia_ManBoxNum(p) ? Tim_ManPiNum((Tim_Man_t *)p->pManTime) : Gia_ManCiNum(p);
1059 int * pDelays = Vec_IntArray(p->vLevels);
1060 int i, k, iBox, iBoxOutId, Delay, Delay0, Delay1, DelayMax = 0, nBoxes = 0;
1061 Vec_IntFill( p->vLevels, Gia_ManObjNum(p), 0 );
1062 Gia_ManForEachObj1( p, pObj, i )
1063 {
1064 if ( Gia_ObjIsCi(pObj) )
1065 {
1066 if ( fIgnoreBoxDelays )
1067 continue;
1068 // check if it is real PI
1069 iBoxOutId = Gia_ObjCioId(pObj) - nRealPis;
1070 if ( iBoxOutId < 0 )
1071 continue;
1072 // if it is a box output, find box number
1073 iBox = iBoxOutId / 2;
1074 assert( iBox < Gia_ManBoxNum(p) );
1075 // check find the maximum delay of the box inputs
1076 Delay = 0;
1077 for ( k = 0; k < 3; k++ )
1078 {
1079 int Id = Gia_ObjId( p, Gia_ManCo(p, iBox*3+k) );
1080 assert( Id < i );
1081 Delay = Abc_MaxInt( Delay, pDelays[Id] );
1082 }
1083 // consider outputs
1084 if ( iBoxOutId & 1 ) // carry output
1085 Delay += DelayC;
1086 else // sum output
1087 Delay += 100;
1088 pDelays[i] = Delay;
1089 continue;
1090 }
1091 if ( Gia_ObjIsCo(pObj) )
1092 {
1093 pDelays[i] = pDelays[Gia_ObjFaninId0(pObj, i)];
1094 DelayMax = Abc_MaxInt( DelayMax, pDelays[i] );
1095 continue;
1096 }
1097 assert( !pObj->fMark0 || !pObj->fMark1 );
1098 Delay0 = pDelays[Gia_ObjFaninId0(pObj, i)];
1099 Delay1 = pDelays[Gia_ObjFaninId1(pObj, i)];
1100 if ( pObj->fMark0 )
1101 {
1102 Delay = Abc_MaxInt( Delay0 + DelayC, Delay1 + 100 );
1103 nBoxes++;
1104 }
1105 else if ( pObj->fMark1 )
1106 {
1107 Delay = Abc_MaxInt( Delay1 + DelayC, Delay0 + 100 );
1108 nBoxes++;
1109 }
1110 else
1111 Delay = Abc_MaxInt( Delay0 + 100, Delay1 + 100 );
1112 pDelays[i] = Delay;
1113 }
1114 if ( pnBoxes )
1115 *pnBoxes = nBoxes;
1116 return DelayMax;
1117}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManFindChains()

void Gia_ManFindChains ( Gia_Man_t * p,
Vec_Int_t * vFadds,
Vec_Int_t * vMap )

Definition at line 520 of file acecFadds.c.

521{
522 int i;
523 // for each FADD find the longest chain rooted in it
524 Vec_Int_t * vLength = Vec_IntStartFull( Gia_ManObjNum(p) );
525 Dtc_ForEachFadd( vFadds, i )
526 Gia_ManFindChains_rec( p, Vec_IntEntry(vFadds, 5*i+4), vFadds, vMap, vLength );
527 Vec_IntFree( vLength );
528}
int Gia_ManFindChains_rec(Gia_Man_t *p, int iMaj, Vec_Int_t *vFadds, Vec_Int_t *vMap, Vec_Int_t *vLength)
Definition acecFadds.c:489
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManFindChains_rec()

int Gia_ManFindChains_rec ( Gia_Man_t * p,
int iMaj,
Vec_Int_t * vFadds,
Vec_Int_t * vMap,
Vec_Int_t * vLength )

Definition at line 489 of file acecFadds.c.

490{
491 assert( Vec_IntEntry(vMap, iMaj) >= 0 ); // MAJ
492 if ( Vec_IntEntry(vLength, iMaj) >= 0 )
493 return Vec_IntEntry(vLength, iMaj);
494 assert( Gia_ObjIsAnd(Gia_ManObj(p, iMaj)) );
495 {
496 int iFadd = Vec_IntEntry( vMap, iMaj );
497 int iXor0 = Vec_IntEntry( vFadds, 5*iFadd+0 );
498 int iXor1 = Vec_IntEntry( vFadds, 5*iFadd+1 );
499 int iXor2 = Vec_IntEntry( vFadds, 5*iFadd+2 );
500 int iLen0 = Vec_IntEntry( vMap, iXor0 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor0, vFadds, vMap, vLength );
501 int iLen1 = Vec_IntEntry( vMap, iXor1 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor1, vFadds, vMap, vLength );
502 int iLen2 = Vec_IntEntry( vMap, iXor2 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor2, vFadds, vMap, vLength );
503 int iLen = Abc_MaxInt( iLen0, Abc_MaxInt(iLen1, iLen2) );
504 if ( iLen0 < iLen )
505 {
506 if ( iLen == iLen1 )
507 {
508 ABC_SWAP( int, Vec_IntArray(vFadds)[5*iFadd+0], Vec_IntArray(vFadds)[5*iFadd+1] );
509 }
510 else if ( iLen == iLen2 )
511 {
512 ABC_SWAP( int, Vec_IntArray(vFadds)[5*iFadd+0], Vec_IntArray(vFadds)[5*iFadd+2] );
513 }
514 }
515 Vec_IntWriteEntry( vLength, iMaj, iLen + 1 );
516 return iLen + 1;
517 }
518}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManFindChainStart()

int Gia_ManFindChainStart ( Gia_Man_t * p)

Definition at line 1124 of file acecFadds.c.

1125{
1126 Gia_Obj_t * pObj;
1127 int * pDelays = Vec_IntArray(p->vLevels);
1128 int i, iMax = -1, DelayMax = 0;
1129 Gia_ManForEachAnd( p, pObj, i )
1130 {
1131 if ( Gia_ObjIsUsed(pObj) )
1132 continue;
1133 if ( DelayMax > pDelays[i] )
1134 continue;
1135 DelayMax = pDelays[i];
1136 iMax = i;
1137 }
1138 return iMax;
1139}
Here is the caller graph for this function:

◆ Gia_ManFindMapping()

Vec_Int_t * Gia_ManFindMapping ( Gia_Man_t * p,
Vec_Int_t * vFadds,
Vec_Int_t * vMap,
Vec_Wec_t * vChains )

Definition at line 620 of file acecFadds.c.

621{
622 Vec_Int_t * vChain;
623 int i, k, iFadd = -1;
624 Vec_Int_t * vMap2Chain = Vec_IntStartFull( Gia_ManObjNum(p) );
625 Vec_WecForEachLevel( vChains, vChain, i )
626 {
627 assert( Vec_IntSize(vChain) > 0 );
628 Vec_IntForEachEntry( vChain, iFadd, k )
629 {
630 //printf( "Chain %d: setting SUM %d (obj %d)\n", i, k, Vec_IntEntry(vFadds, 5*iFadd+3) );
631 assert( Vec_IntEntry(vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+3)) == -1 );
632 Vec_IntWriteEntry( vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+3), i );
633 }
634 //printf( "Chain %d: setting CARRY (obj %d)\n", i, Vec_IntEntry(vFadds, 5*iFadd+4) );
635 assert( Vec_IntEntry(vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+4)) == -1 );
636 Vec_IntWriteEntry( vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+4), i );
637 }
638 return vMap2Chain;
639}
Here is the caller graph for this function:

◆ Gia_ManFindPath()

int Gia_ManFindPath ( Gia_Man_t * p,
int DelayC,
int nPathMin,
int nPathMax,
Vec_Int_t * vPath )

Definition at line 1141 of file acecFadds.c.

1142{
1143 Gia_Obj_t * pObj, * pFanin0, * pFanin1;
1144 int * pDelays = Vec_IntArray(p->vLevels);
1145 int i, iLit, iMax = Gia_ManFindChainStart( p );
1146 if ( iMax == -1 )
1147 return -1;
1148 Vec_IntClear( vPath );
1149 pObj = Gia_ManObj(p, iMax);
1150 assert( Gia_ObjIsAnd(pObj) );
1151 while ( Gia_ObjIsAnd(pObj) )
1152 {
1153 assert( !Gia_ObjIsUsed(pObj) );
1154 pFanin0 = Gia_ObjFanin0(pObj);
1155 pFanin1 = Gia_ObjFanin1(pObj);
1156 if ( Gia_ObjIsUsed(pFanin0) && Gia_ObjIsUsed(pFanin1) )
1157 break;
1158 if ( Gia_ObjIsUsed(pFanin0) )
1159 {
1160 Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 1) );
1161 pObj = pFanin1;
1162 }
1163 else if ( Gia_ObjIsUsed(pFanin1) )
1164 {
1165 Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 0) );
1166 pObj = pFanin0;
1167 }
1168 else
1169 {
1170 if ( pDelays[Gia_ObjId(p, pFanin1)] > pDelays[Gia_ObjId(p, pFanin0)] )
1171 {
1172 Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 1) );
1173 pObj = pFanin1;
1174 }
1175 else
1176 {
1177 Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 0) );
1178 pObj = pFanin0;
1179 }
1180 }
1181 }
1182 if ( Vec_IntSize(vPath) < nPathMin )
1183 {
1184 Gia_ManObj(p, iMax)->fPhase = 1;
1185 return 0;
1186 }
1187 // label nodes
1188 if ( Vec_IntSize(vPath) > nPathMax )
1189 Vec_IntShrink( vPath, nPathMax );
1190 Vec_IntForEachEntry( vPath, iLit, i )
1191 {
1192 pObj = Gia_ManObj( p, Abc_Lit2Var(iLit) );
1193 if ( Abc_LitIsCompl(iLit) )
1194 {
1195 assert( pObj->fMark1 == 0 );
1196 pObj->fMark1 = 1;
1197 assert( Gia_ObjFanin1(pObj)->fPhase == 0 );
1198 Gia_ObjFanin1(pObj)->fPhase = 1;
1199 }
1200 else
1201 {
1202 assert( pObj->fMark0 == 0 );
1203 pObj->fMark0 = 1;
1204 assert( Gia_ObjFanin0(pObj)->fPhase == 0 );
1205 Gia_ObjFanin0(pObj)->fPhase = 1;
1206 }
1207 }
1208 return Vec_IntSize(vPath);
1209}
int Gia_ManFindChainStart(Gia_Man_t *p)
Definition acecFadds.c:1124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenerateDelayTableFloat()

float * Gia_ManGenerateDelayTableFloat ( int nIns,
int nOuts )

Definition at line 670 of file acecFadds.c.

671{
672 int i, Total = nIns * nOuts;
673 float * pDelayTable = ABC_ALLOC( float, Total + 3 );
674 pDelayTable[0] = 0;
675 pDelayTable[1] = nIns;
676 pDelayTable[2] = nOuts;
677 for ( i = 0; i < Total; i++ )
678 pDelayTable[i+3] = 1;
679 pDelayTable[i+3 - nIns] = -ABC_INFINITY;
680 return pDelayTable;
681}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
Here is the caller graph for this function:

◆ Gia_ManGenerateExtraAig()

Gia_Man_t * Gia_ManGenerateExtraAig ( int nBoxes,
int nIns,
int nOuts )

Definition at line 704 of file acecFadds.c.

705{
706 Gia_Man_t * pNew = Gia_ManStart( nBoxes * 20 );
707 int i, k, pInLits[16], pOutLits[16];
708 assert( nIns < 16 && nOuts < 16 );
709 for ( i = 0; i < nIns; i++ )
710 pInLits[i] = Gia_ManAppendCi( pNew );
711 pOutLits[0] = Gia_ManAppendXor( pNew, Gia_ManAppendXor(pNew, pInLits[0], pInLits[1]), pInLits[2] );
712 pOutLits[1] = Gia_ManAppendMaj( pNew, pInLits[0], pInLits[1], pInLits[2] );
713 for ( i = 0; i < nBoxes; i++ )
714 for ( k = 0; k < nOuts; k++ )
715 Gia_ManAppendCo( pNew, pOutLits[k] );
716 return pNew;
717}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGenerateTim()

Tim_Man_t * Gia_ManGenerateTim ( int nPis,
int nPos,
int nBoxes,
int nIns,
int nOuts )

Definition at line 682 of file acecFadds.c.

683{
684 Tim_Man_t * pMan;
685 int i, curPi, curPo;
686 Vec_Ptr_t * vDelayTables = Vec_PtrAlloc( 1 );
687 Vec_PtrPush( vDelayTables, Gia_ManGenerateDelayTableFloat(nIns, nOuts) );
688 pMan = Tim_ManStart( nPis + nOuts * nBoxes, nPos + nIns * nBoxes );
689 Tim_ManSetDelayTables( pMan, vDelayTables );
690 curPi = nPis;
691 curPo = 0;
692 for ( i = 0; i < nBoxes; i++ )
693 {
694 Tim_ManCreateBox( pMan, curPo, nIns, curPi, nOuts, 0, 0 );
695 curPi += nOuts;
696 curPo += nIns;
697 }
698 curPo += nPos;
699 assert( curPi == Tim_ManCiNum(pMan) );
700 assert( curPo == Tim_ManCoNum(pMan) );
701 //Tim_ManPrint( pMan );
702 return pMan;
703}
float * Gia_ManGenerateDelayTableFloat(int nIns, int nOuts)
Definition acecFadds.c:670
void Tim_ManSetDelayTables(Tim_Man_t *p, Vec_Ptr_t *vDelayTables)
Definition timMan.c:765
int Tim_ManCiNum(Tim_Man_t *p)
Definition timMan.c:700
void Tim_ManCreateBox(Tim_Man_t *p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable, int fBlack)
ITERATORS ///.
Definition timBox.c:44
Tim_Man_t * Tim_ManStart(int nCis, int nCos)
DECLARATIONS ///.
Definition timMan.c:45
int Tim_ManCoNum(Tim_Man_t *p)
Definition timMan.c:704
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManIllustrateBoxes()

void Gia_ManIllustrateBoxes ( Gia_Man_t * p)

Function*************************************************************

Synopsis [Derive GIA with boxes containing adder-chains.]

Description []

SideEffects []

SeeAlso []

Definition at line 140 of file acecFadds.c.

141{
142 Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
143 int nBoxes = Tim_ManBoxNum( pManTime );
144 int i, k, curCi, curCo, nBoxIns, nBoxOuts;
145 Gia_Obj_t * pObj;
146 // walk through the boxes
147 curCi = Tim_ManPiNum(pManTime);
148 curCo = 0;
149 for ( i = 0; i < nBoxes; i++ )
150 {
151 nBoxIns = Tim_ManBoxInputNum(pManTime, i);
152 nBoxOuts = Tim_ManBoxOutputNum(pManTime, i);
153 printf( "Box %4d [%d x %d] : ", i, nBoxIns, nBoxOuts );
154 printf( "Input obj IDs = " );
155 for ( k = 0; k < nBoxIns; k++ )
156 {
157 pObj = Gia_ManCo( p, curCo + k );
158 printf( "%d ", Gia_ObjId(p, pObj) );
159 }
160 printf( " Output obj IDs = " );
161 for ( k = 0; k < nBoxOuts; k++ )
162 {
163 pObj = Gia_ManCi( p, curCi + k );
164 printf( "%d ", Gia_ObjId(p, pObj) );
165 }
166 curCo += nBoxIns;
167 curCi += nBoxOuts;
168 printf( "\n" );
169 }
170 curCo += Tim_ManPoNum(pManTime);
171 // verify counts
172 assert( curCi == Gia_ManCiNum(p) );
173 assert( curCo == Gia_ManCoNum(p) );
174}
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
Definition timBox.c:203
int Tim_ManBoxNum(Tim_Man_t *p)
Definition timMan.c:722
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition timBox.c:187
Here is the call graph for this function:

◆ Gia_ManIteratePaths()

int Gia_ManIteratePaths ( Gia_Man_t * p,
int DelayC,
int nPathMin,
int nPathMax,
int nPathLimit,
int fIgnoreBoxDelays,
int fVerbose )

Definition at line 1211 of file acecFadds.c.

1212{
1213 Gia_Obj_t * pObj;
1214 Vec_Int_t * vPath = Vec_IntAlloc( 100 );
1215 int i, RetValue, nBoxes, MaxDelay, nPaths = 0;
1216 assert( p->vLevels == NULL );
1217 p->vLevels = Vec_IntStart( Gia_ManObjNum(p) );
1220 Gia_ManForEachCi( p, pObj, i )
1221 pObj->fPhase = 1;
1222 if ( fVerbose )
1223 printf( "Running path detection: BoxDelay = %d, PathMin = %d, PathMax = %d, PathLimit = %d.\n", DelayC, nPathMin, nPathMax, nPathLimit );
1224 for ( i = 0; i < nPathLimit; i++ )
1225 {
1226 MaxDelay = Gia_ManFindAnnotatedDelay( p, DelayC, &nBoxes, fIgnoreBoxDelays );
1227 RetValue = Gia_ManFindPath( p, DelayC, nPathMin, nPathMax, vPath );
1228 if ( RetValue == -1 )
1229 break;
1230 nPaths += (RetValue > 0);
1231 if ( fVerbose )
1232 printf( "Iter %5d : Paths = %2d. Boxes = %2d. Total boxes = %6d. Max delay = %5d.\n", i, nPaths, RetValue, nBoxes, MaxDelay );
1233 }
1234 Vec_IntFree( vPath );
1235 Vec_IntFreeP( &p->vLevels );
1237 return 1;
1238}
int Gia_ManFindPath(Gia_Man_t *p, int DelayC, int nPathMin, int nPathMax, Vec_Int_t *vPath)
Definition acecFadds.c:1141
int Gia_ManFindAnnotatedDelay(Gia_Man_t *p, int DelayC, int *pnBoxes, int fIgnoreBoxDelays)
Definition acecFadds.c:1055
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManMarkWithTravId_rec()

void Gia_ManMarkWithTravId_rec ( Gia_Man_t * p,
int Id )

Definition at line 543 of file acecFadds.c.

544{
545 Gia_Obj_t * pObj;
546 if ( Gia_ObjIsTravIdCurrentId(p, Id) )
547 return;
548 Gia_ObjSetTravIdCurrentId(p, Id);
549 pObj = Gia_ManObj( p, Id );
550 if ( Gia_ObjIsAnd(pObj) )
551 Gia_ManMarkWithTravId_rec( p, Gia_ObjFaninId0(pObj, Id) );
552 if ( Gia_ObjIsAnd(pObj) )
553 Gia_ManMarkWithTravId_rec( p, Gia_ObjFaninId1(pObj, Id) );
554}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManPrintChains()

void Gia_ManPrintChains ( Gia_Man_t * p,
Vec_Int_t * vFadds,
Vec_Int_t * vMap,
Vec_Wec_t * vChains )

Definition at line 590 of file acecFadds.c.

591{
592 Vec_Int_t * vChain;
593 int i, k, iFadd, Count = 0;
594 Vec_WecForEachLevel( vChains, vChain, i )
595 {
596 Count += Vec_IntSize(vChain);
597 if ( i < 10 )
598 {
599 printf( "Chain %4d : %4d ", i, Vec_IntSize(vChain) );
600 Vec_IntForEachEntry( vChain, iFadd, k )
601 {
602 printf( "%d(%d) ", iFadd, Vec_IntEntry(vFadds, 5*iFadd+4) );
603 if ( k != Vec_IntSize(vChain) - 1 )
604 printf( "-> " );
605 if ( k > 6 )
606 {
607 printf( "..." );
608 break;
609 }
610 }
611 printf( "\n" );
612 }
613 else if ( i == 10 )
614 printf( "...\n" );
615
616 }
617 printf( "Total chains = %d. Total full-adders = %d.\n", Vec_WecSize(vChains), Count );
618}
Here is the caller graph for this function:

◆ Gia_ObjFanin0CopyCarry()

int Gia_ObjFanin0CopyCarry ( Vec_Int_t * vCarries,
Gia_Obj_t * pObj,
int Id )

Function*************************************************************

Synopsis [Converting AIG with annotated carry-chains into AIG with boxes.]

Description [Assumes that annotations are pObj->fMark0 or pObj->fMark1. Only one of these can be set to 1. If fMark0 (fMark1) is set to 1, the first (second) input of an AND-gate is chained.]

SideEffects []

SeeAlso []

Definition at line 909 of file acecFadds.c.

910{
911 if ( vCarries == NULL || Vec_IntEntry(vCarries, Gia_ObjFaninId0(pObj, Id)) == -1 )
912 return Gia_ObjFanin0Copy(pObj);
913 return Abc_LitNotCond( Vec_IntEntry(vCarries, Gia_ObjFaninId0(pObj, Id)), Gia_ObjFaninC0(pObj) );
914}
Here is the caller graph for this function:

◆ Gia_ObjFanin1CopyCarry()

int Gia_ObjFanin1CopyCarry ( Vec_Int_t * vCarries,
Gia_Obj_t * pObj,
int Id )

Definition at line 915 of file acecFadds.c.

916{
917 if ( vCarries == NULL || Vec_IntEntry(vCarries, Gia_ObjFaninId1(pObj, Id)) == -1 )
918 return Gia_ObjFanin1Copy(pObj);
919 return Abc_LitNotCond( Vec_IntEntry(vCarries, Gia_ObjFaninId1(pObj, Id)), Gia_ObjFaninC1(pObj) );
920}
Here is the caller graph for this function: