summaryrefslogtreecommitdiffstats
path: root/src/map/if
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
commit6130e39b18b5f53902e4eab14f6d5cdde5219563 (patch)
tree0db0628479a1b750e9af1f66cb8379ebd0913d31 /src/map/if
parentf0e77f6797c0504b0da25a56152b707d3357f386 (diff)
downloadabc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.gz
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.bz2
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.zip
initial commit of public abc
Diffstat (limited to 'src/map/if')
-rw-r--r--src/map/if/if.h75
-rw-r--r--src/map/if/ifCore.c16
-rw-r--r--src/map/if/ifCut.c49
-rw-r--r--src/map/if/ifLib.c31
-rw-r--r--src/map/if/ifMan.c33
-rw-r--r--src/map/if/ifMap.c46
-rw-r--r--src/map/if/ifReduce.c29
-rw-r--r--src/map/if/ifSeq.c45
-rw-r--r--src/map/if/ifTime.c374
-rw-r--r--src/map/if/ifTruth.c6
-rw-r--r--src/map/if/ifUtil.c71
-rw-r--r--src/map/if/if_.c5
12 files changed, 649 insertions, 131 deletions
diff --git a/src/map/if/if.h b/src/map/if/if.h
index 91d6e037..96f6f109 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -21,10 +21,11 @@
#ifndef __IF_H__
#define __IF_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
-
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,9 +35,10 @@
#include "mem.h"
#include "tim.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
@@ -92,8 +94,10 @@ struct If_Par_t_
int fCutMin; // performs cut minimization by removing functionally reducdant variables
int fSeqMap; // sequential mapping
int fBidec; // use bi-decomposition
+ int fUseBat; // use one specialized feature
int fVerbose; // the verbosity flag
// internal parameters
+ int fDelayOpt; // special delay optimization
int fAreaOnly; // area only mode
int fTruth; // truth table computation enabled
int fUsePerm; // use permutation (delay info)
@@ -101,13 +105,16 @@ struct If_Par_t_
int fUseSops; // use local SOPs as a cost function
int fUseCnfs; // use local CNFs as a cost function
int fUseMv; // use local MV-SOPs as a cost function
+ int fUseAdders; // timing model for adders
int nLatches; // the number of latches in seq mapping
int fLiftLeaves; // shift the leaves for seq mapping
+ int fUseCoAttrs; // use CO attributes
If_Lib_t * pLutLib; // the LUT library
float * pTimesArr; // arrival times
float * pTimesReq; // required times
int (* pFuncCost) (If_Cut_t *); // procedure to compute the user's cost of a cut
int (* pFuncUser) (If_Man_t *, If_Obj_t *, If_Cut_t *); // procedure called for each cut when cut computation is finished
+ int (* pFuncCell) (unsigned *, int, int); // procedure called for cut functions
void * pReoMan; // reordering manager
};
@@ -166,10 +173,13 @@ struct If_Man_t_
Mem_Fixed_t * pMemSet; // memory manager for sets of cuts (entrysize = nCutSize*(nCutsMax+1))
If_Set_t * pMemCi; // memory for CI cutsets
If_Set_t * pMemAnd; // memory for AND cutsets
- If_Set_t * pFreeList; // the list of ABC_FREE cutsets
+ If_Set_t * pFreeList; // the list of free cutsets
int nSmallSupp; // the small support
+ int nCutsTotal;
+ int nCutsUseless;
// timing manager
Tim_Man_t * pManTim;
+ Vec_Int_t * vCoAttrs; // CO attributes 0=optimize; 1=keep; 2=relax
// statistics
// int timeTruth;
};
@@ -183,9 +193,10 @@ struct If_Cut_t_
float Power; // the power flow
float Delay; // delay of the cut
unsigned uSign; // cut signature
- unsigned Cost : 14; // the user's cost of the cut
+ unsigned Cost : 13; // the user's cost of the cut
unsigned fCompl : 1; // the complemented attribute
unsigned fUser : 1; // using the user's area and delay
+ unsigned fUseless: 1; // using the user's area and delay
unsigned nLimit : 8; // the maximum number of leaves
unsigned nLeaves : 8; // the number of leaves
int * pLeaves; // array of fanins
@@ -198,7 +209,7 @@ struct If_Set_t_
{
short nCutsMax; // the max number of cuts
short nCuts; // the current number of cuts
- If_Set_t * pNext; // next cutset in the ABC_FREE list
+ If_Set_t * pNext; // next cutset in the free list
If_Cut_t ** ppCuts; // the array of pointers to the cuts
};
@@ -212,7 +223,8 @@ struct If_Obj_t_
unsigned fRepr : 1; // representative of the equivalence class
unsigned fMark : 1; // multipurpose mark
unsigned fVisit : 1; // multipurpose mark
- unsigned Level : 22; // logic level of the node
+ unsigned fSpec : 1; // multipurpose mark
+ unsigned Level : 21; // logic level of the node
int Id; // integer ID
int IdPio; // integer ID of PIs/POs
int nRefs; // the number of references
@@ -229,6 +241,18 @@ struct If_Obj_t_
If_Cut_t CutBest; // the best cut selected
};
+typedef struct If_And_t_ If_And_t;
+struct If_And_t_
+{
+ unsigned iFan0 : 15; // fanin0
+ unsigned fCompl0 : 1; // compl fanin0
+ unsigned iFan1 : 15; // fanin1
+ unsigned fCompl1 : 1; // compl fanin1
+ unsigned Id : 15; // Id
+ unsigned fCompl : 1; // compl output
+ unsigned Delay : 16; // delay
+};
+
static inline If_Obj_t * If_Regular( If_Obj_t * p ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
static inline If_Obj_t * If_Not( If_Obj_t * p ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
static inline If_Obj_t * If_NotCond( If_Obj_t * p, int c ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
@@ -253,6 +277,7 @@ static inline int If_ObjIsTerm( If_Obj_t * pObj ) { r
static inline int If_ObjIsLatch( If_Obj_t * pObj ) { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL; }
static inline int If_ObjIsAnd( If_Obj_t * pObj ) { return pObj->Type == IF_AND; }
+static inline int If_ObjId( If_Obj_t * pObj ) { return pObj->Id; }
static inline If_Obj_t * If_ObjFanin0( If_Obj_t * pObj ) { return pObj->pFanin0; }
static inline If_Obj_t * If_ObjFanin1( If_Obj_t * pObj ) { return pObj->pFanin1; }
static inline int If_ObjFaninC0( If_Obj_t * pObj ) { return pObj->fCompl0; }
@@ -275,6 +300,9 @@ static inline void If_ObjSetLValue( If_Obj_t * pObj, float LValue ) { p
static inline void * If_CutData( If_Cut_t * pCut ) { return *(void **)pCut; }
static inline void If_CutSetData( If_Cut_t * pCut, void * pData ) { *(void **)pCut = pData; }
+static inline int If_CutDataInt( If_Cut_t * pCut ) { return *(int *)pCut; }
+static inline void If_CutSetDataInt( If_Cut_t * pCut, int Data ) { *(int *)pCut = Data; }
+
static inline int If_CutLeaveNum( If_Cut_t * pCut ) { return pCut->nLeaves; }
static inline int * If_CutLeaves( If_Cut_t * pCut ) { return pCut->pLeaves; }
static inline unsigned * If_CutTruth( If_Cut_t * pCut ) { return pCut->pTruth; }
@@ -284,6 +312,11 @@ static inline int If_CutPermWords( int nVarsMax ) { r
static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { return pCut->fUser? (float)pCut->Cost : (p->pPars->pLutLib? p->pPars->pLutLib->pLutAreas[pCut->nLeaves] : (float)1.0); }
+static inline word If_AndToWrd( If_And_t m ) { union { If_And_t x; word y; } v; v.x = m; return v.y; }
+static inline If_And_t If_WrdToAnd( word m ) { union { If_And_t x; word y; } v; v.y = m; return v.x; }
+static inline void If_AndClear( If_And_t * pNode ) { *pNode = If_WrdToAnd(0); }
+
+
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -298,27 +331,27 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r
// iterator over the primary inputs
#define If_ManForEachCi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCis, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vCis, pObj, i )
// iterator over the primary outputs
#define If_ManForEachCo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCos, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vCos, pObj, i )
// iterator over the primary inputs
#define If_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
// iterator over the primary outputs
#define If_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStop( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
// iterator over the latches
#define If_ManForEachLatchInput( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStart( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
#define If_ManForEachLatchOutput( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStart( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
// iterator over all objects in topological order
#define If_ManForEachObj( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vObjs, pObj, i )
// iterator over all objects in reverse topological order
#define If_ManForEachObjReverse( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjsRev, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vObjsRev, pObj, i )
// iterator over logic nodes
#define If_ManForEachNode( p, pObj, i ) \
If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
@@ -404,6 +437,8 @@ extern void If_ManImproveMapping( If_Man_t * p );
/*=== ifSeq.c =============================================================*/
extern int If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
+extern int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut );
+extern Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutDelay( If_Man_t * p, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float Required );
extern void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
@@ -427,14 +462,12 @@ extern void If_ManMarkMapping( If_Man_t * p );
extern Vec_Ptr_t * If_ManCollectMappingDirect( If_Man_t * p );
extern Vec_Int_t * If_ManCollectMappingInt( If_Man_t * p );
-
extern int If_ManCountSpecialPos( If_Man_t * p );
+// othe packages
+extern int Bat_ManCellFuncLookup( unsigned * pTruth, int nVars, int nLeaves );
-
-#ifdef __cplusplus
-}
-#endif
+ABC_NAMESPACE_HEADER_END
#endif
diff --git a/src/map/if/ifCore.c b/src/map/if/ifCore.c
index e3fd47f1..fcecb401 100644
--- a/src/map/if/ifCore.c
+++ b/src/map/if/ifCore.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -56,7 +59,7 @@ int If_ManPerformMapping( If_Man_t * p )
if ( p->pPars->fSeqMap )
{
// if ( p->pPars->fVerbose )
- printf( "Performing sequential mapping without retiming.\n" );
+ Abc_Print( 1, "Performing sequential mapping without retiming.\n" );
return If_ManPerformMappingSeq( p );
}
return If_ManPerformMappingComb( p );
@@ -128,21 +131,20 @@ int If_ManPerformMappingComb( If_Man_t * p )
if ( p->pPars->fVerbose )
{
-// printf( "Total memory = %7.2f Mb. Peak cut memory = %7.2f Mb. ",
+// Abc_Print( 1, "Total memory = %7.2f Mb. Peak cut memory = %7.2f Mb. ",
// 1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
// 1.0 * p->nSetBytes * Mem_FixedReadMaxEntriesUsed(p->pMemSet) / (1<<20) );
- ABC_PRT( "Total time", clock() - clkTotal );
+ Abc_PrintTime( 1, "Total time", clock() - clkTotal );
}
-// printf( "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) );
+// Abc_Print( 1, "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) );
s_MappingTime = clock() - clkTotal;
-// printf( "Special POs = %d.\n", If_ManCountSpecialPos(p) );
+// Abc_Print( 1, "Special POs = %d.\n", If_ManCountSpecialPos(p) );
{
extern int If_CutGetCones( If_Man_t * p );
extern int If_CutCountTotalFanins( If_Man_t * p );
// If_CutGetCones( p );
// If_CutCountTotalFanins( p );
}
-
return 1;
}
@@ -151,3 +153,5 @@ int If_ManPerformMappingComb( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c
index d3ce5397..58224692 100644
--- a/src/map/if/ifCut.c
+++ b/src/map/if/ifCut.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -440,7 +443,7 @@ static inline int If_ManSortCompare( If_Man_t * p, If_Cut_t * pC0, If_Cut_t * pC
return -1;
if ( pC0->Area > pC1->Area + p->fEpsilon )
return 1;
- //printf("area(%.2f, %.2f), power(%.2f, %.2f), edge(%.2f, %.2f)\n",
+ //Abc_Print( 1,"area(%.2f, %.2f), power(%.2f, %.2f), edge(%.2f, %.2f)\n",
// pC0->Area, pC1->Area, pC0->Power, pC1->Power, pC0->Edge, pC1->Edge);
if ( pC0->Power < pC1->Power - p->fEpsilon )
return -1;
@@ -511,7 +514,7 @@ static inline int If_ManSortCompare( If_Man_t * p, If_Cut_t * pC0, If_Cut_t * pC
return 1;
return 0;
}
- else // reglar
+ else // regular
{
if ( p->SortMode == 1 ) // area
{
@@ -682,16 +685,28 @@ void If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut )
return;
}
+ if ( p->pPars->fUseBat && !pCut->fUseless )
+ {
+ If_Cut_t * pFirst = pCutSet->ppCuts[0];
+ if ( pFirst->fUseless || If_ManSortCompare(p, pFirst, pCut) == 1 )
+ {
+ pCutSet->ppCuts[0] = pCut;
+ pCutSet->ppCuts[pCutSet->nCuts] = pFirst;
+ If_CutSort( p, pCutSet, pFirst );
+ return;
+ }
+ }
+
// the cut will be added - find its place
for ( i = pCutSet->nCuts-1; i >= 0; i-- )
{
// Counter++;
- if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 )
+ if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 || (i == 0 && !pCutSet->ppCuts[0]->fUseless && pCut->fUseless) )
break;
pCutSet->ppCuts[i+1] = pCutSet->ppCuts[i];
pCutSet->ppCuts[i] = pCut;
}
-// printf( "%d ", Counter );
+// Abc_Print( 1, "%d ", Counter );
// update the number of cuts
if ( pCutSet->nCuts < pCutSet->nCutsMax )
@@ -746,7 +761,7 @@ int If_CutCheck( If_Cut_t * pCut )
{
if ( pCut->pLeaves[i-1] >= pCut->pLeaves[i] )
{
- printf( "If_CutCheck(): Cut has wrong ordering of inputs.\n" );
+ Abc_Print( -1, "If_CutCheck(): Cut has wrong ordering of inputs.\n" );
return 0;
}
assert( pCut->pLeaves[i-1] < pCut->pLeaves[i] );
@@ -769,10 +784,10 @@ int If_CutCheck( If_Cut_t * pCut )
void If_CutPrint( If_Cut_t * pCut )
{
unsigned i;
- printf( "{" );
+ Abc_Print( 1, "{" );
for ( i = 0; i < pCut->nLeaves; i++ )
- printf( " %d", pCut->pLeaves[i] );
- printf( " }\n" );
+ Abc_Print( 1, " %d", pCut->pLeaves[i] );
+ Abc_Print( 1, " }\n" );
}
/**Function*************************************************************
@@ -790,10 +805,10 @@ void If_CutPrintTiming( If_Man_t * p, If_Cut_t * pCut )
{
If_Obj_t * pLeaf;
unsigned i;
- printf( "{" );
+ Abc_Print( 1, "{" );
If_CutForEachLeaf( p, pCut, pLeaf, i )
- printf( " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required );
- printf( " }\n" );
+ Abc_Print( 1, " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required );
+ Abc_Print( 1, " }\n" );
}
/**Function*************************************************************
@@ -1345,11 +1360,11 @@ int If_CutGetCones( If_Man_t * p )
if ( If_ObjIsAnd(pObj) && pObj->nRefs )
{
Counter += !If_CutGetCone_rec( p, pObj, If_ObjCutBest(pObj) );
-// printf( "%d ", If_CutGetCutMinLevel( p, If_ObjCutBest(pObj) ) );
+// Abc_Print( 1, "%d ", If_CutGetCutMinLevel( p, If_ObjCutBest(pObj) ) );
}
}
- printf( "Cound not find boundary for %d nodes.\n", Counter );
- ABC_PRT( "Cones", clock() - clk );
+ Abc_Print( 1, "Cound not find boundary for %d nodes.\n", Counter );
+ Abc_PrintTime( 1, "Cones", clock() - clk );
return 1;
}
@@ -1405,8 +1420,8 @@ int If_CutCountTotalFanins( If_Man_t * p )
Counter += Vec_IntSize(vLeaves);
}
}
- printf( "Total cut inputs = %d. Total fanins incremental = %d.\n", nFaninsTotal, Counter );
- ABC_PRT( "Fanins", clock() - clk );
+ Abc_Print( 1, "Total cut inputs = %d. Total fanins incremental = %d.\n", nFaninsTotal, Counter );
+ Abc_PrintTime( 1, "Fanins", clock() - clk );
Vec_IntFree( vLeaves );
return 1;
}
@@ -1416,3 +1431,5 @@ int If_CutCountTotalFanins( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifLib.c b/src/map/if/ifLib.c
index 176edb24..90e37a0f 100644
--- a/src/map/if/ifLib.c
+++ b/src/map/if/ifLib.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -51,7 +54,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
pFile = fopen( FileName, "r" );
if ( pFile == NULL )
{
- printf( "Cannot open LUT library file \"%s\".\n", FileName );
+ Abc_Print( -1, "Cannot open LUT library file \"%s\".\n", FileName );
return NULL;
}
@@ -69,7 +72,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
continue;
if ( i != atoi(pToken) )
{
- printf( "Error in the LUT library file \"%s\".\n", FileName );
+ Abc_Print( 1, "Error in the LUT library file \"%s\".\n", FileName );
ABC_FREE( p );
return NULL;
}
@@ -86,7 +89,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
// check for out-of-bound
if ( k > i )
{
- printf( "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
+ Abc_Print( 1, "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
return NULL;
}
@@ -96,7 +99,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
if ( i == IF_MAX_LUTSIZE )
{
- printf( "Skipping LUTs of size more than %d.\n", i );
+ Abc_Print( 1, "Skipping LUTs of size more than %d.\n", i );
return NULL;
}
i++;
@@ -110,10 +113,10 @@ If_Lib_t * If_LutLibRead( char * FileName )
for ( k = 0; k < i; k++ )
{
if ( p->pLutDelays[i][k] <= 0.0 )
- printf( "Warning: Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
+ Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
k, i, p->pLutDelays[i][k] );
if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
- printf( "Warning: Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
+ Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
k-1, i, p->pLutDelays[i][k-1],
k, i, p->pLutDelays[i][k] );
}
@@ -123,7 +126,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
for ( i = 1; i <= p->LutMax; i++ )
{
if ( p->pLutDelays[i][0] <= 0.0 )
- printf( "Warning: LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
+ Abc_Print( 0, "LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
i, p->pLutDelays[i][0] );
}
}
@@ -185,21 +188,21 @@ void If_LutLibFree( If_Lib_t * pLutLib )
void If_LutLibPrint( If_Lib_t * pLutLib )
{
int i, k;
- printf( "# The area/delay of k-variable LUTs:\n" );
- printf( "# k area delay\n" );
+ Abc_Print( 1, "# The area/delay of k-variable LUTs:\n" );
+ Abc_Print( 1, "# k area delay\n" );
if ( pLutLib->fVarPinDelays )
{
for ( i = 1; i <= pLutLib->LutMax; i++ )
{
- printf( "%d %7.2f ", i, pLutLib->pLutAreas[i] );
+ Abc_Print( 1, "%d %7.2f ", i, pLutLib->pLutAreas[i] );
for ( k = 0; k < i; k++ )
- printf( " %7.2f", pLutLib->pLutDelays[i][k] );
- printf( "\n" );
+ Abc_Print( 1, " %7.2f", pLutLib->pLutDelays[i][k] );
+ Abc_Print( 1, "\n" );
}
}
else
for ( i = 1; i <= pLutLib->LutMax; i++ )
- printf( "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
+ Abc_Print( 1, "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
}
/**Function*************************************************************
@@ -334,3 +337,5 @@ float If_LutLibSlowestPinDelay( If_Lib_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c
index 6294e3d2..f0c37e70 100644
--- a/src/map/if/ifMan.c
+++ b/src/map/if/ifMan.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,14 +53,14 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
// start the manager
p = ABC_ALLOC( If_Man_t, 1 );
memset( p, 0, sizeof(If_Man_t) );
- p->pPars = pPars;
+ p->pPars = pPars;
p->fEpsilon = pPars->Epsilon;
// allocate arrays for nodes
- p->vCis = Vec_PtrAlloc( 100 );
- p->vCos = Vec_PtrAlloc( 100 );
- p->vObjs = Vec_PtrAlloc( 100 );
+ p->vCis = Vec_PtrAlloc( 100 );
+ p->vCos = Vec_PtrAlloc( 100 );
+ p->vObjs = Vec_PtrAlloc( 100 );
// p->vMapped = Vec_PtrAlloc( 100 );
- p->vTemp = Vec_PtrAlloc( 100 );
+ p->vTemp = Vec_PtrAlloc( 100 );
// prepare the memory manager
p->nTruthWords = p->pPars->fTruth? If_CutTruthWords( p->pPars->nLutSize ) : 0;
p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0;
@@ -68,7 +71,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
// p->pMemSet = Mem_FixedStart( p->nSetBytes );
// report expected memory usage
if ( p->pPars->fVerbose )
- printf( "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d.\n",
+ Abc_Print( 1, "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d.\n",
p->pPars->nLutSize, 4 * p->nTruthWords, p->nCutBytes, p->nObjBytes, p->nSetBytes );
// room for temporary truth tables
p->puTemp[0] = p->pPars->fTruth? ABC_ALLOC( unsigned, 4 * p->nTruthWords ) : NULL;
@@ -76,7 +79,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
// create the constant node
- p->pConst1 = If_ManSetupObj( p );
+ p->pConst1 = If_ManSetupObj( p );
p->pConst1->Type = IF_CONST1;
p->pConst1->fPhase = 1;
p->nObjs[IF_CONST1]++;
@@ -124,8 +127,11 @@ void If_ManRestart( If_Man_t * p )
***********************************************************************/
void If_ManStop( If_Man_t * p )
{
-// ABC_PRT( "Truth", p->timeTruth );
-// printf( "Small support = %d.\n", p->nSmallSupp );
+ if ( p->nCutsUseless && p->pPars->fVerbose )
+ Abc_Print( 1, "Useless cuts = %7d (out of %7d) (%6.2f %%)\n", p->nCutsUseless, p->nCutsTotal, 100.0*p->nCutsUseless/(p->nCutsTotal+1) );
+// Abc_PrintTime( 1, "Truth", p->timeTruth );
+// Abc_Print( 1, "Small support = %d.\n", p->nSmallSupp );
+ Vec_IntFreeP( &p->vCoAttrs );
Vec_PtrFree( p->vCis );
Vec_PtrFree( p->vCos );
Vec_PtrFree( p->vObjs );
@@ -192,6 +198,7 @@ If_Obj_t * If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver )
pObj->Type = IF_CO;
pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver);
pObj->pFanin0 = pDriver; pDriver->nRefs++;
+ pObj->fPhase = (pObj->fCompl0 ^ pDriver->fPhase);
pObj->Level = pDriver->Level;
if ( p->nLevelMax < (int)pObj->Level )
p->nLevelMax = (int)pObj->Level;
@@ -379,6 +386,8 @@ void If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId )
for ( i = 0; i < nTruthWords; i++ )
If_CutTruth(pCut)[i] = 0xAAAAAAAA;
}
+
+ assert( pCut->pLeaves[0] < p->vObjs->nSize );
}
/**Function*************************************************************
@@ -566,12 +575,12 @@ void If_ManSetupSetAll( If_Man_t * p, int nCrossCut )
if ( p->pPars->fVerbose )
{
- printf( "Node = %7d. Ch = %5d. Total mem = %7.2f Mb. Peak cut mem = %7.2f Mb.\n",
+ Abc_Print( 1, "Node = %7d. Ch = %5d. Total mem = %7.2f Mb. Peak cut mem = %7.2f Mb.\n",
If_ManAndNum(p), p->nChoices,
1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
1.0 * p->nSetBytes * nCrossCut / (1<<20) );
}
-// printf( "Cross cut = %d.\n", nCrossCut );
+// Abc_Print( 1, "Cross cut = %d.\n", nCrossCut );
}
@@ -580,3 +589,5 @@ void If_ManSetupSetAll( If_Man_t * p, int nCrossCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifMap.c b/src/map/if/ifMap.c
index ca57868d..66e59d2f 100644
--- a/src/map/if/ifMap.c
+++ b/src/map/if/ifMap.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -87,10 +90,13 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( pCut->nLeaves > 0 )
{
// recompute the parameters of the best cut
- pCut->Delay = If_CutDelay( p, pCut );
+ if ( p->pPars->fDelayOpt )
+ pCut->Delay = If_CutDelaySopCost( p, pCut );
+ else
+ pCut->Delay = If_CutDelay( p, pCut );
// assert( pCut->Delay <= pObj->Required + p->fEpsilon );
if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
- printf( "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
+ Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
pObj->Id, pCut->Delay, pObj->Required + p->fEpsilon );
pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
if ( p->pPars->fEdge )
@@ -106,17 +112,20 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
If_ObjForEachCut( pObj->pFanin0, pCut0, i )
If_ObjForEachCut( pObj->pFanin1, pCut1, k )
{
- // get the next ABC_FREE cut
+ // get the next free cut
assert( pCutSet->nCuts <= pCutSet->nCutsMax );
pCut = pCutSet->ppCuts[pCutSet->nCuts];
// make sure K-feasible cut exists
if ( If_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->pPars->nLutSize )
continue;
- // merge the nodes
+ // merge the cuts
if ( !If_CutMerge( pCut0, pCut1, pCut ) )
continue;
+ if ( pObj->fSpec && pCut->nLeaves == (unsigned)p->pPars->nLutSize )
+ continue;
assert( p->pPars->fSeqMap || pCut->nLeaves > 1 );
p->nCutsMerged++;
+ p->nCutsTotal++;
// check if this cut is contained in any of the available cuts
// if ( p->pPars->pFuncCost == NULL && If_CutFilter( p, pCut ) ) // do not filter functionality cuts
if ( If_CutFilter( pCutSet, pCut ) )
@@ -128,6 +137,12 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// int clk = clock();
If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
// p->timeTruth += clock() - clk;
+ if ( p->pPars->pFuncCell )
+ {
+ assert( pCut->nLimit >= 4 && pCut->nLimit <= 6 );
+ pCut->fUseless = !p->pPars->pFuncCell( If_CutTruth(pCut), pCut->nLimit, pCut->nLeaves );
+ p->nCutsUseless += pCut->fUseless;
+ }
}
// compute the application-specific cost and depth
pCut->fUser = (p->pPars->pFuncCost != NULL);
@@ -135,8 +150,11 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( pCut->Cost == IF_COST_MAX )
continue;
// check if the cut satisfies the required times
- pCut->Delay = If_CutDelay( p, pCut );
-// printf( "%.2f ", pCut->Delay );
+ if ( p->pPars->fDelayOpt )
+ pCut->Delay = If_CutDelaySopCost( p, pCut );
+ else
+ pCut->Delay = If_CutDelay( p, pCut );
+// Abc_Print( 1, "%.2f ", pCut->Delay );
if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
continue;
// compute area of the cut (this area may depend on the application specific cost)
@@ -163,6 +181,8 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// ref the selected cut
if ( Mode && pObj->nRefs > 0 )
If_CutAreaRef( p, If_ObjCutBest(pObj) );
+ if ( If_ObjCutBest(pObj)->fUseless )
+ Abc_Print( 1, "The best cut is useless.\n" );
// call the user specified function for each cut
if ( p->pPars->pFuncUser )
@@ -214,7 +234,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
If_ObjForEachCut( pTemp, pCutTemp, i )
{
assert( p->pPars->fSeqMap || pCutTemp->nLeaves > 1 );
- // get the next ABC_FREE cut
+ // get the next free cut
assert( pCutSet->nCuts <= pCutSet->nCutsMax );
pCut = pCutSet->ppCuts[pCutSet->nCuts];
// copy the cut into storage
@@ -239,7 +259,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
// insert the cut into storage
If_CutSort( p, pCutSet, pCut );
}
- }
+ }
assert( pCutSet->nCuts > 0 );
// add the trivial cut to the set
@@ -304,7 +324,7 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
}
else if ( If_ObjIsCi(pObj) )
{
-//printf( "processing CI %d\n", pObj->Id );
+//Abc_Print( 1, "processing CI %d\n", pObj->Id );
arrTime = Tim_ManGetCiArrival( p->pManTim, pObj->IdPio );
If_ObjSetArrTime( pObj, arrTime );
}
@@ -342,10 +362,10 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
if ( p->pPars->fVerbose )
{
char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
- printf( "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
+ Abc_Print( 1, "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
Symb, p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged );
- ABC_PRT( "T", clock() - clk );
-// printf( "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
+ Abc_PrintTime( 1, "T", clock() - clk );
+// Abc_Print( 1, "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
// p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
}
return 1;
@@ -357,3 +377,5 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifReduce.c b/src/map/if/ifReduce.c
index b3130600..622688e7 100644
--- a/src/map/if/ifReduce.c
+++ b/src/map/if/ifReduce.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,9 +58,9 @@ void If_ManImproveMapping( If_Man_t * p )
If_ManComputeRequired( p );
if ( p->pPars->fVerbose )
{
- printf( "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
+ Abc_Print( 1, "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
/*
@@ -66,9 +69,9 @@ void If_ManImproveMapping( If_Man_t * p )
If_ManComputeRequired( p, 0 );
if ( p->pPars->fVerbose )
{
- printf( "R: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
+ Abc_Print( 1, "R: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
p->RequiredGlo, p->AreaGlo, p->nNets, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
*/
/*
@@ -77,9 +80,9 @@ void If_ManImproveMapping( If_Man_t * p )
If_ManComputeRequired( p, 0 );
if ( p->pPars->fVerbose )
{
- printf( "E: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
+ Abc_Print( 1, "E: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
p->RequiredGlo, p->AreaGlo, p->nNets, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
*/
}
@@ -126,7 +129,7 @@ int If_ManImproveCutCost( If_Man_t * p, Vec_Ptr_t * vFront )
{
If_Obj_t * pFanin;
int i, Counter = 0;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
if ( pFanin->nRefs == 0 )
Counter++;
return Counter;
@@ -170,7 +173,7 @@ void If_ManImproveNodeExpand( If_Man_t * p, If_Obj_t * pObj, int nLimit, Vec_Ptr
If_CutAreaRef( p, pCut );
assert( CostBef >= CostAft );
// clean up
- Vec_PtrForEachEntry( vVisited, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vVisited, pFanin, i )
pFanin->fMark = 0;
// update the node
If_ManImproveNodeUpdate( p, pObj, vFront );
@@ -261,7 +264,7 @@ void If_ManImproveNodeUpdate( If_Man_t * p, If_Obj_t * pObj, Vec_Ptr_t * vFront
If_CutAreaDeref( p, pCut );
// update the node's cut
pCut->nLeaves = Vec_PtrSize(vFront);
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
pCut->pLeaves[i] = pFanin->Id;
If_CutOrder( pCut );
// ref the new cut
@@ -363,7 +366,7 @@ int If_ManImproveNodeFaninCompact0( If_Man_t * p, If_Obj_t * pObj, int nLimit, V
{
If_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
{
if ( If_ObjIsCi(pFanin) )
continue;
@@ -393,7 +396,7 @@ int If_ManImproveNodeFaninCompact1( If_Man_t * p, If_Obj_t * pObj, int nLimit, V
{
If_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
{
if ( If_ObjIsCi(pFanin) )
continue;
@@ -421,7 +424,7 @@ int If_ManImproveNodeFaninCompact2( If_Man_t * p, If_Obj_t * pObj, int nLimit, V
{
If_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
{
if ( If_ObjIsCi(pFanin) )
continue;
@@ -574,3 +577,5 @@ void If_ManImproveReduce( If_Man_t * p, int nLimit )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifSeq.c b/src/map/if/ifSeq.c
index e4e27e71..8b5808d5 100644
--- a/src/map/if/ifSeq.c
+++ b/src/map/if/ifSeq.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -99,7 +102,7 @@ Vec_Ptr_t * If_ManCollectLatches( If_Man_t * p )
If_ManForEachLatchOutput( p, pObj, i )
If_ManCollectLatches_rec( pObj, vLatches );
// clean marks
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vLatches, pObj, i )
pObj->fMark = 0;
assert( Vec_PtrSize(vLatches) == p->pPars->nLatches );
return vLatches;
@@ -127,7 +130,7 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
if ( nIter == 1 )
{
// if some latches depend on PIs, update their values
- Vec_PtrForEachEntry( p->vLatchOrder, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vLatchOrder, pObj, i )
{
If_ObjSetLValue( pObj, If_ObjLValue(If_ObjFanin0(pObj)) - p->Period );
If_ObjSetArrTime( pObj, If_ObjLValue(pObj) );
@@ -144,7 +147,7 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
}
// postprocess the mapping
-//printf( "Itereation %d: \n", nIter );
+//Abc_Print( 1, "Itereation %d: \n", nIter );
If_ManForEachNode( p, pObj, i )
{
// update the LValues stored separately
@@ -153,15 +156,15 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
If_ObjSetLValue( pObj, If_ObjCutBest(pObj)->Delay );
fChange = 1;
}
-//printf( "%d ", (int)If_ObjLValue(pObj) );
+//Abc_Print( 1, "%d ", (int)If_ObjLValue(pObj) );
// reset the visit counters
assert( pObj->nVisits == 0 );
pObj->nVisits = pObj->nVisitsCopy;
}
-//printf( "\n" );
+//Abc_Print( 1, "\n" );
// propagate LValues over the registers
- Vec_PtrForEachEntry( p->vLatchOrder, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vLatchOrder, pObj, i )
{
If_ObjSetLValue( pObj, If_ObjLValue(If_ObjFanin0(pObj)) - p->Period );
If_ObjSetArrTime( pObj, If_ObjLValue(pObj) );
@@ -173,9 +176,9 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
{
p->RequiredGlo = If_ManDelayMax( p, 1 );
// p->AreaGlo = If_ManScanMapping(p);
- printf( "S%d: Fi = %6.2f. Del = %6.2f. Area = %8.2f. Cuts = %8d. ",
+ Abc_Print( 1, "S%d: Fi = %6.2f. Del = %6.2f. Area = %8.2f. Cuts = %8d. ",
nIter, (float)p->Period, p->RequiredGlo, p->AreaGlo, p->nCutsMerged );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
return fChange;
}
@@ -228,7 +231,7 @@ int If_ManBinarySearchPeriod( If_Man_t * p )
break;
}
p->RequiredGlo = If_ManDelayMax( p, 1 );
-//printf( "Global = %d \n", (int)p->RequiredGlo );
+//Abc_Print( 1, "Global = %d \n", (int)p->RequiredGlo );
if ( p->RequiredGlo > p->Period + p->fEpsilon )
break;
}
@@ -238,14 +241,14 @@ int If_ManBinarySearchPeriod( If_Man_t * p )
if ( p->pPars->fVerbose )
{
// p->AreaGlo = If_ManScanMapping(p);
- printf( "Attempt = %2d. Iters = %3d. Area = %10.2f. Fi = %6.2f. ", p->nAttempts, c, p->AreaGlo, (float)p->Period );
+ Abc_Print( 1, "Attempt = %2d. Iters = %3d. Area = %10.2f. Fi = %6.2f. ", p->nAttempts, c, p->AreaGlo, (float)p->Period );
if ( fConverged )
- printf( " Feasible" );
+ Abc_Print( 1, " Feasible" );
else if ( c > p->nMaxIters )
- printf( "Infeasible (timeout)" );
+ Abc_Print( 1, "Infeasible (timeout)" );
else
- printf( "Infeasible" );
- printf( "\n" );
+ Abc_Print( 1, "Infeasible" );
+ Abc_Print( 1, "\n" );
}
return fConverged;
}
@@ -302,12 +305,12 @@ void If_ManPerformMappingSeqPost( If_Man_t * p )
If_ManForEachPo( p, pObj, i )
{
p->pPars->pTimesReq[i] = p->RequiredGlo2;
-// printf( "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
+// Abc_Print( 1, "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
}
If_ManForEachLatchInput( p, pObjLi, i )
{
p->pPars->pTimesReq[i] = If_ObjLValue(If_ObjFanin0(pObjLi));
-// printf( "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
+// Abc_Print( 1, "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
}
// undo previous mapping
@@ -359,7 +362,7 @@ int If_ManPerformMappingSeq( If_Man_t * p )
// make sure the clock period works
if ( !If_ManBinarySearchPeriod( p ) )
{
- printf( "If_ManPerformMappingSeq(): The upper bound on the clock period cannot be computed.\n" );
+ Abc_Print( 1, "If_ManPerformMappingSeq(): The upper bound on the clock period cannot be computed.\n" );
return 0;
}
@@ -372,14 +375,14 @@ int If_ManPerformMappingSeq( If_Man_t * p )
p->Period = PeriodBest;
if ( !If_ManBinarySearchPeriod( p ) )
{
- printf( "If_ManPerformMappingSeq(): The final clock period cannot be confirmed.\n" );
+ Abc_Print( 1, "If_ManPerformMappingSeq(): The final clock period cannot be confirmed.\n" );
return 0;
}
}
// if ( p->pPars->fVerbose )
{
- printf( "The best clock period is %3d. ", p->Period );
- ABC_PRT( "Time", clock() - clkTotal );
+ Abc_Print( 1, "The best clock period is %3d. ", p->Period );
+ Abc_PrintTime( 1, "Time", clock() - clkTotal );
}
p->RequiredGlo = (float)(PeriodBest);
@@ -394,3 +397,5 @@ int If_ManPerformMappingSeq( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifTime.c b/src/map/if/ifTime.c
index 20521805..bfe0d969 100644
--- a/src/map/if/ifTime.c
+++ b/src/map/if/ifTime.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "if.h"
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -32,6 +36,363 @@ static void If_CutSortInputPins( If_Man_t * p, If_Cut_t * pCut, int * pPinPerm,
/**Function*************************************************************
+ Synopsis [Inserts the entry while sorting them by delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+word If_AndVerifyArray( Vec_Wrd_t * vAnds, int nVars )
+{
+ Vec_Wrd_t * vTruths;
+ If_And_t This;
+ word Entry, Truth0, Truth1, TruthR;
+ int i;
+ static word Truth[8] = {
+ 0xAAAAAAAAAAAAAAAA,
+ 0xCCCCCCCCCCCCCCCC,
+ 0xF0F0F0F0F0F0F0F0,
+ 0xFF00FF00FF00FF00,
+ 0xFFFF0000FFFF0000,
+ 0xFFFFFFFF00000000,
+ 0x0000000000000000,
+ 0xFFFFFFFFFFFFFFFF
+ };
+ if ( Vec_WrdSize(vAnds) == 0 )
+ return Truth[6];
+ if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds,0) == 0 )
+ return Truth[7];
+ vTruths = Vec_WrdAlloc( Vec_WrdSize(vAnds) );
+ for ( i = 0; i < nVars; i++ )
+ Vec_WrdPush( vTruths, Truth[i] );
+ Vec_WrdForEachEntryStart( vAnds, Entry, i, nVars )
+ {
+ This = If_WrdToAnd(Entry);
+ Truth0 = Vec_WrdEntry( vTruths, This.iFan0 );
+ Truth0 = This.fCompl0 ? ~Truth0 : Truth0;
+ Truth1 = Vec_WrdEntry( vTruths, This.iFan1 );
+ Truth1 = This.fCompl1 ? ~Truth1 : Truth1;
+ TruthR = Truth0 & Truth1;
+ Vec_WrdPush( vTruths, TruthR );
+ }
+ Vec_WrdFree( vTruths );
+ TruthR = This.fCompl ? ~TruthR : TruthR;
+ return TruthR;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts the entry while sorting them by delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_AndInsertSorted( Vec_Wrd_t * vAnds, If_And_t And )
+{
+ If_And_t This, Prev;
+ int i;
+ Vec_WrdPush( vAnds, If_AndToWrd(And) );
+ for ( i = Vec_WrdSize(vAnds) - 1; i > 0; i-- )
+ {
+ This = If_WrdToAnd( Vec_WrdEntry(vAnds, i) );
+ Prev = If_WrdToAnd( Vec_WrdEntry(vAnds, i-1) );
+ if ( This.Delay <= Prev.Delay )
+ break;
+ Vec_WrdWriteEntry( vAnds, i, If_AndToWrd(Prev) );
+ Vec_WrdWriteEntry( vAnds, i-1, If_AndToWrd(This) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Decomposes the cube into a bunch of AND gates.]
+
+ Description [Records the result of decomposition into vLits. Returns
+ the last AND gate of the decomposition.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_And_t If_CutDelaySopCube( Vec_Wrd_t * vCube, Vec_Wrd_t * vAnds, int fOrGate )
+{
+ If_And_t This, Prev, Next;
+ assert( Vec_WrdSize(vCube) > 0 );
+ while ( Vec_WrdSize(vCube) > 1 )
+ {
+ // get last
+ This = If_WrdToAnd( Vec_WrdPop(vCube) );
+ Prev = If_WrdToAnd( Vec_WrdPop(vCube) );
+ // create new
+ If_AndClear( &Next );
+ Next.iFan0 = Prev.Id;
+ Next.fCompl0 = Prev.fCompl ^ fOrGate;
+ Next.iFan1 = This.Id;
+ Next.fCompl1 = This.fCompl ^ fOrGate;
+ Next.Id = Vec_WrdSize(vAnds);
+ Next.fCompl = fOrGate;
+ Next.Delay = 1 + ABC_MAX( This.Delay, Prev.Delay );
+ // add new
+ If_AndInsertSorted( vCube, Next );
+ Vec_WrdPush( vAnds, If_AndToWrd(Next) );
+ }
+ return If_WrdToAnd( Vec_WrdPop(vCube) );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the well-balanced structure of AIG nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Wrd_t * If_CutDelaySopAnds( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vCover, int fCompl )
+{
+ Vec_Wrd_t * vAnds, * vAndGate, * vOrGate;
+ If_Obj_t * pLeaf;
+ If_And_t Leaf;
+ int i, k, Entry, Literal;
+ vAnds = Vec_WrdAlloc( 32 );
+ if ( Vec_IntSize(vCover) == 0 ) // const 0
+ {
+ assert( fCompl == 0 );
+ return vAnds;
+ }
+ if ( Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0 ) // const 1
+ {
+ assert( fCompl == 0 );
+ Vec_WrdPush( vAnds, 0 );
+ return vAnds;
+ }
+ If_CutForEachLeaf( p, pCut, pLeaf, k )
+ {
+ If_AndClear( &Leaf );
+ Leaf.Id = k;
+ Leaf.Delay = (int)If_ObjCutBest(pLeaf)->Delay;
+ Vec_WrdPush( vAnds, If_AndToWrd(Leaf) );
+ }
+ // iterate through the cubes
+ vOrGate = Vec_WrdAlloc( 16 );
+ vAndGate = Vec_WrdAlloc( 16 );
+ Vec_IntForEachEntry( vCover, Entry, i )
+ {
+ Vec_WrdClear( vAndGate );
+ If_CutForEachLeaf( p, pCut, pLeaf, k )
+ {
+ Literal = 3 & (Entry >> (k << 1));
+ if ( Literal == 1 ) // neg literal
+ {
+ If_AndClear( &Leaf );
+ Leaf.fCompl = 1;
+ Leaf.Id = k;
+ Leaf.Delay = (int)If_ObjCutBest(pLeaf)->Delay;
+ If_AndInsertSorted( vAndGate, Leaf );
+ }
+ else if ( Literal == 2 ) // pos literal
+ {
+ If_AndClear( &Leaf );
+ Leaf.Id = k;
+ Leaf.Delay = (int)If_ObjCutBest(pLeaf)->Delay;
+ If_AndInsertSorted( vAndGate, Leaf );
+ }
+ else if ( Literal != 0 )
+ assert( 0 );
+ }
+ Leaf = If_CutDelaySopCube( vAndGate, vAnds, 0 );
+ If_AndInsertSorted( vOrGate, Leaf );
+ }
+ Leaf = If_CutDelaySopCube( vOrGate, vAnds, 1 );
+ Vec_WrdFree( vAndGate );
+ Vec_WrdFree( vOrGate );
+ if ( Vec_WrdSize(vAnds) == (int)pCut->nLeaves )
+ {
+// Extra_PrintBinary( stdout, If_CutTruth(pCut), 32 ); printf( "\n" );
+ assert( Leaf.Id < pCut->nLeaves );
+ Leaf.iFan0 = Leaf.iFan1 = Leaf.Id;
+ Leaf.Id = Vec_WrdSize(vAnds);
+ Vec_WrdPush( vAnds, If_AndToWrd(Leaf) );
+ }
+ if ( fCompl )
+ {
+ Leaf = If_WrdToAnd( Vec_WrdPop(vAnds) );
+ Leaf.fCompl ^= 1;
+ Vec_WrdPush( vAnds, If_AndToWrd(Leaf) );
+ }
+ return vAnds;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes balanced AND decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut )
+{
+ Vec_Int_t * vCover;
+ Vec_Wrd_t * vAnds;
+ int RetValue;
+ vCover = Vec_IntAlloc(0);
+ RetValue = Kit_TruthIsop( If_CutTruth(pCut), If_CutLeaveNum(pCut), vCover, 1 );
+ if ( RetValue == -1 )
+ {
+ Vec_IntFree( vCover );
+ return NULL;
+ }
+ assert( RetValue == 0 || RetValue == 1 );
+ vAnds = If_CutDelaySopAnds( p, pCut, vCover, RetValue ^ pCut->fCompl );
+/*
+ if ( pCut->nLeaves <= 5 )
+ {
+ if ( *If_CutTruth(pCut) != (unsigned)If_AndVerifyArray(vAnds, pCut->nLeaves) )
+ {
+ unsigned Truth0 = *If_CutTruth(pCut);
+ unsigned Truth1 = (unsigned)If_AndVerifyArray(vAnds, pCut->nLeaves);
+
+ printf( "\n" );
+ Extra_PrintBinary( stdout, &Truth0, 32 ); printf( "\n" );
+ Extra_PrintBinary( stdout, &Truth1, 32 ); printf( "\n" );
+
+ printf( "Verification failed for %d vars.\n", pCut->nLeaves );
+ }
+// else
+// printf( "Verification passed for %d vars.\n", pCut->nLeaves );
+ }
+ else if ( pCut->nLeaves == 6 )
+ {
+ if ( *((word *)If_CutTruth(pCut)) != If_AndVerifyArray(vAnds, pCut->nLeaves) )
+ printf( "Verification failed for %d vars.\n", pCut->nLeaves );
+// else
+// printf( "Verification passed for %d vars.\n", pCut->nLeaves );
+ }
+*/
+ Vec_IntFree( vCover );
+ return vAnds;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Derives the maximum depth from the leaf to the root.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutDelayLeafDepth_rec( Vec_Wrd_t * vAnds, If_And_t And, int iLeaf )
+{
+ int Depth0, Depth1, Depth;
+ if ( (int)And.Id == iLeaf )
+ return 0;
+ if ( And.iFan0 == And.iFan1 )
+ return -100;
+ Depth0 = If_CutDelayLeafDepth_rec( vAnds, If_WrdToAnd(Vec_WrdEntry(vAnds, And.iFan0)), iLeaf );
+ Depth1 = If_CutDelayLeafDepth_rec( vAnds, If_WrdToAnd(Vec_WrdEntry(vAnds, And.iFan1)), iLeaf );
+ Depth = ABC_MAX( Depth0, Depth1 );
+ Depth = (Depth == -100) ? -100 : Depth + 1;
+ return Depth;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the maximum depth from the leaf to the root.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutDelayLeafDepth( Vec_Wrd_t * vAnds, int iLeaf )
+{
+ If_And_t Leaf;
+ if ( Vec_WrdSize(vAnds) == 0 ) // const 0
+ return -100;
+ if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds, 0) == 0 ) // const 1
+ return -100;
+ Leaf = If_WrdToAnd(Vec_WrdEntryLast(vAnds));
+ if ( Leaf.iFan0 == Leaf.iFan1 )
+ {
+ if ( (int)Leaf.iFan0 == iLeaf )
+ return 0;
+ return -100;
+ }
+ return If_CutDelayLeafDepth_rec( vAnds, Leaf, iLeaf );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Computes the SOP delay using balanced AND decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_And_t Leaf;
+ Vec_Wrd_t * vAnds;
+ int i;//, Delay;
+ // mark cut as a user cut
+ pCut->fUser = 1;
+ vAnds = If_CutDelaySopArray( p, pCut );
+ if ( vAnds == NULL )
+ {
+ assert( 0 );
+ return ABC_INFINITY;
+ }
+ // get the cost
+ If_AndClear( &Leaf );
+ if ( Vec_WrdSize(vAnds) )
+ Leaf = If_WrdToAnd( Vec_WrdEntryLast(vAnds) );
+ if ( pCut->nLeaves > 2 && Vec_WrdSize(vAnds) > (int)pCut->nLeaves )
+ pCut->Cost = Vec_WrdSize(vAnds) - pCut->nLeaves;
+ else
+ pCut->Cost = 1;
+ // get the permutation
+ for ( i = 0; i < (int)pCut->nLeaves; i++ )
+ pCut->pPerm[i] = If_CutDelayLeafDepth( vAnds, i );
+ Vec_WrdFree( vAnds );
+ // verify the delay
+// Delay = If_CutDelay( p, pCut );
+// assert( (int)Leaf.Delay == Delay );
+ return Leaf.Delay;
+}
+
+
+
+
+
+
+/**Function*************************************************************
+
Synopsis [Computes delay.]
Description []
@@ -81,7 +442,7 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
assert( !p->pPars->fLiftLeaves );
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
- DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)pCut->pPerm[i];
+ DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)(pCut->pPerm ? pCut->pPerm[i] : 1.0);
Delay = IF_MAX( Delay, DelayCur );
}
}
@@ -99,13 +460,6 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
{
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
-/*
- if ( pLeaf->IdPio > 2000 )
- {
- int x = 0;
- printf( "-%d %6.3f ", pLeaf->IdPio, If_ObjCutBest(pLeaf)->Delay );
- }
-*/
DelayCur = If_ObjCutBest(pLeaf)->Delay;
Delay = IF_MAX( Delay, DelayCur );
}
@@ -164,7 +518,7 @@ void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float ObjRequired )
{
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
- Required = ObjRequired - (float)pCut->pPerm[i];
+ Required = ObjRequired - (float)(pCut->pPerm ? pCut->pPerm[i] : 1.0);
pLeaf->Required = IF_MIN( pLeaf->Required, Required );
}
}
@@ -252,3 +606,5 @@ void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifTruth.c b/src/map/if/ifTruth.c
index 637a42b4..75bc49db 100644
--- a/src/map/if/ifTruth.c
+++ b/src/map/if/ifTruth.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -414,6 +417,7 @@ int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut )
// if ( If_CutLeaveNum(pCut) - nSuppSize > 1 )
// return 0;
//printf( "%d %d ", If_CutLeaveNum(pCut), nSuppSize );
+// pCut->fUseless = 1;
// shrink the truth table
If_TruthShrink( p->puTemp[0], If_CutTruth(pCut), nSuppSize, pCut->nLimit, uSupport, 1 );
@@ -440,3 +444,5 @@ int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c
index 1e6d7704..da3a4aa5 100644
--- a/src/map/if/ifUtil.c
+++ b/src/map/if/ifUtil.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -103,7 +106,7 @@ float If_ManDelayMax( If_Man_t * p, int fSeq )
int i;
if ( p->pPars->fLatchPaths && p->pPars->nLatches == 0 )
{
- printf( "Delay optimization of latch path is not performed because there is no latches.\n" );
+ Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" );
p->pPars->fLatchPaths = 0;
}
DelayBest = -IF_FLOAT_LARGE;
@@ -163,18 +166,25 @@ void If_ManComputeRequired( If_Man_t * p )
if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
{
Counter++;
- // printf( "Required times are violated for output %d (arr = %d; req = %d).\n",
+ // Abc_Print( 0, "Required times are violated for output %d (arr = %d; req = %d).\n",
// i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
}
If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
}
if ( Counter )
- printf( "Required times are violated for %d outputs.\n", Counter );
+ Abc_Print( 0, "Required times are violated for %d outputs.\n", Counter );
}
else
{
// get the global required times
p->RequiredGlo = If_ManDelayMax( p, 0 );
+/*
+ ////////////////////////////////////////
+ // redefine the delay target (positive number means percentage)
+ if ( p->pPars->DelayTarget > 0 )
+ p->pPars->DelayTarget = p->RequiredGlo * (100.0 + p->pPars->DelayTarget) / 100.0;
+ ////////////////////////////////////////
+*/
// update the required times according to the target
if ( p->pPars->DelayTarget != -1 )
{
@@ -183,7 +193,7 @@ void If_ManComputeRequired( If_Man_t * p )
if ( p->fNextRound == 0 )
{
p->fNextRound = 1;
- printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
+ Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
}
}
else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
@@ -191,7 +201,7 @@ void If_ManComputeRequired( If_Man_t * p )
if ( p->fNextRound == 0 )
{
p->fNextRound = 1;
- printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
}
p->RequiredGlo = p->pPars->DelayTarget;
}
@@ -212,7 +222,7 @@ void If_ManComputeRequired( If_Man_t * p )
}
}
// go through the nodes in the reverse topological order
- // Vec_PtrForEachEntry( p->vMapped, pObj, i )
+ // Vec_PtrForEachEntry( If_Obj_t *, p->vMapped, pObj, i )
// If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
If_ManForEachObjReverse( p, pObj, i )
{
@@ -225,12 +235,49 @@ void If_ManComputeRequired( If_Man_t * p )
{
// get the global required times
p->RequiredGlo = If_ManDelayMax( p, 0 );
+ // update the required times according to the target
+ if ( p->pPars->DelayTarget != -1 )
+ {
+ if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
+ {
+ if ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+ Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
+ }
+ }
+ else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
+ {
+ if ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+ }
+ p->RequiredGlo = p->pPars->DelayTarget;
+ }
+ }
// do not propagate required times if area minimization is requested
if ( p->pPars->fAreaOnly )
return;
// set the required times for the POs
Tim_ManIncrementTravId( p->pManTim );
- if ( p->pPars->fLatchPaths )
+ if ( p->vCoAttrs )
+ {
+ assert( If_ManCoNum(p) == Vec_IntSize(p->vCoAttrs) );
+ If_ManForEachCo( p, pObj, i )
+ {
+ if ( Vec_IntEntry(p->vCoAttrs, i) == -1 ) // -1=internal
+ continue;
+ if ( Vec_IntEntry(p->vCoAttrs, i) == 0 ) // 0=optimize
+ Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
+ else if ( Vec_IntEntry(p->vCoAttrs, i) == 1 ) // 1=keep
+ Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
+ else if ( Vec_IntEntry(p->vCoAttrs, i) == 2 ) // 2=relax
+ Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
+ else assert( 0 );
+ }
+ }
+ else if ( p->pPars->fLatchPaths )
{
assert( 0 );
If_ManForEachPo( p, pObj, i )
@@ -529,7 +576,7 @@ int If_ManCrossCut( If_Man_t * p )
pObj->nVisits = pObj->nVisitsCopy;
}
assert( nCutSize == 0 );
-// printf( "Max cross cut size = %6d.\n", nCutSizeMax );
+// Abc_Print( 1, "Max cross cut size = %6d.\n", nCutSizeMax );
return nCutSizeMax;
}
@@ -561,12 +608,12 @@ Vec_Ptr_t * If_ManReverseOrder( If_Man_t * p )
}
vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
for ( i = p->nLevelMax; i >= 0; i-- )
- for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy )
+ for ( pObj = ppStore[i]; pObj; pObj = (If_Obj_t *)pObj->pCopy )
Vec_PtrPush( vOrder, pObj );
ABC_FREE( ppStore );
// print the order
-// Vec_PtrForEachEntry( vOrder, pObj, i )
-// printf( "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
+// Vec_PtrForEachEntry( If_Obj_t *, vOrder, pObj, i )
+// Abc_Print( 1, "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
return vOrder;
}
@@ -727,3 +774,5 @@ int If_ManCountSpecialPos( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/if_.c b/src/map/if/if_.c
index d2960077..cc7a2162 100644
--- a/src/map/if/if_.c
+++ b/src/map/if/if_.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+