summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2017-07-01 13:48:31 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2017-07-01 13:48:31 -0700
commitbf6a053c648576c1e5493f2d5390eb78b2e3df1c (patch)
tree19c0e561e0d56178c40bb1030ccd738fa5455501
parenta1dd7e3fb04660e025f8cb37eb2636d3d700c3ac (diff)
downloadabc-bf6a053c648576c1e5493f2d5390eb78b2e3df1c.tar.gz
abc-bf6a053c648576c1e5493f2d5390eb78b2e3df1c.tar.bz2
abc-bf6a053c648576c1e5493f2d5390eb78b2e3df1c.zip
Saturating floating point computation.
-rw-r--r--src/aig/gia/giaLf.c6
-rw-r--r--src/aig/gia/giaNf.c6
-rw-r--r--src/base/cmd/cmdHist.c2
-rw-r--r--src/map/if/ifCut.c10
4 files changed, 18 insertions, 6 deletions
diff --git a/src/aig/gia/giaLf.c b/src/aig/gia/giaLf.c
index 2c216a9b..15ec3529 100644
--- a/src/aig/gia/giaLf.c
+++ b/src/aig/gia/giaLf.c
@@ -1154,7 +1154,11 @@ static inline void Lf_CutParams( Lf_Man_t * p, Lf_Cut_t * pCut, int Required, fl
else
{
Index = (int)(pBest->Delay[1] + 1 <= Required && Required != ABC_INFINITY);
- pCut->Flow += pBest->Flow[Index];
+ //pCut->Flow += pBest->Flow[Index];
+ if ( pCut->Flow >= (float)1e32 || pBest->Flow[Index] >= (float)1e32 )
+ pCut->Flow = (float)1e32;
+ else
+ pCut->Flow += pBest->Flow[Index];
}
Delay = pBest->Delay[Index];
}
diff --git a/src/aig/gia/giaNf.c b/src/aig/gia/giaNf.c
index 6f1d0c8d..403c220a 100644
--- a/src/aig/gia/giaNf.c
+++ b/src/aig/gia/giaNf.c
@@ -1147,7 +1147,11 @@ void Nf_ManCutMatchOne( Nf_Man_t * p, int iObj, int * pCut, int * pCutSet )
if ( pD->D < SCL_INFINITY && pA->D < SCL_INFINITY && ArrivalD + pC->iDelays[k] > Required )
break;
Delay = Abc_MaxInt( Delay, ArrivalD + pC->iDelays[k] );
- AreaF += pBestF[iFanin]->M[fComplF][0].F;
+ //AreaF += pBestF[iFanin]->M[fComplF][0].F;
+ if ( AreaF >= (float)1e32 || pBestF[iFanin]->M[fComplF][0].F >= (float)1e32 )
+ AreaF = (float)1e32;
+ else
+ AreaF += pBestF[iFanin]->M[fComplF][0].F;
}
}
if ( k < nFans )
diff --git a/src/base/cmd/cmdHist.c b/src/base/cmd/cmdHist.c
index 36e546a7..218d832f 100644
--- a/src/base/cmd/cmdHist.c
+++ b/src/base/cmd/cmdHist.c
@@ -57,7 +57,7 @@ void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command )
return;
Len = strlen(command);
strcpy( Buffer, command );
- if ( Buffer[Len-1] == '\n' )
+ if ( Len > 0 && Buffer[Len-1] == '\n' )
Buffer[Len-1] = 0;
if ( strlen(Buffer) > 3 &&
strncmp(Buffer,"set",3) &&
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c
index 9b8d75ad..667a21c5 100644
--- a/src/map/if/ifCut.c
+++ b/src/map/if/ifCut.c
@@ -919,18 +919,22 @@ void If_CutLift( If_Cut_t * pCut )
float If_CutAreaFlow( If_Man_t * p, If_Cut_t * pCut )
{
If_Obj_t * pLeaf;
- float Flow;
+ float Flow, AddOn;
int i;
Flow = If_CutLutArea(p, pCut);
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) )
- Flow += If_ObjCutBest(pLeaf)->Area;
+ AddOn = If_ObjCutBest(pLeaf)->Area;
else
{
assert( pLeaf->EstRefs > p->fEpsilon );
- Flow += If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs;
+ AddOn = If_ObjCutBest(pLeaf)->Area / pLeaf->EstRefs;
}
+ if ( Flow >= (float)1e32 || AddOn >= (float)1e32 )
+ Flow = (float)1e32;
+ else
+ Flow += AddOn;
}
return Flow;
}