summaryrefslogtreecommitdiffstats
path: root/src/map
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-03-27 20:15:02 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-03-27 20:15:02 -0700
commita21f2986aa907e5cf484cd7cd467290d192bf816 (patch)
tree8ae3fc7d1cb6316865bb4c8abc46aead9c91ba16 /src/map
parent08253a50eba6c2b7f0346763c923a5abff20708e (diff)
downloadabc-a21f2986aa907e5cf484cd7cd467290d192bf816.tar.gz
abc-a21f2986aa907e5cf484cd7cd467290d192bf816.tar.bz2
abc-a21f2986aa907e5cf484cd7cd467290d192bf816.zip
Enabling mapping into multi-input AND/OR gates.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/if/if.h3
-rw-r--r--src/map/if/ifCore.c25
-rw-r--r--src/map/if/ifMan.c1
-rw-r--r--src/map/if/ifMap.c14
-rw-r--r--src/map/if/ifTime.c69
5 files changed, 98 insertions, 14 deletions
diff --git a/src/map/if/if.h b/src/map/if/if.h
index 6dda12a7..7a4ab551 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -95,6 +95,7 @@ struct If_Par_t_
int nCutsMax; // the max number of cuts
int nFlowIters; // the number of iterations of area recovery
int nAreaIters; // the number of iterations of area recovery
+ int nGateSize; // the max size of the AND/OR gate to map into
float DelayTarget; // delay target
float Epsilon; // value used in comparison floating point numbers
int fPreprocess; // preprossing
@@ -153,6 +154,7 @@ struct If_Lib_t_
// manager
struct If_Man_t_
{
+ char * pName;
// mapping parameters
If_Par_t * pPars;
// mapping nodes
@@ -487,6 +489,7 @@ extern int If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
extern int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutDelaySopCost2( If_Man_t * p, If_Cut_t * pCut );
+extern int If_CutDelaySop( 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_Obj_t * pObj, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
diff --git a/src/map/if/ifCore.c b/src/map/if/ifCore.c
index fcecb401..9cdddccd 100644
--- a/src/map/if/ifCore.c
+++ b/src/map/if/ifCore.c
@@ -139,12 +139,29 @@ int If_ManPerformMappingComb( If_Man_t * p )
// Abc_Print( 1, "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) );
s_MappingTime = clock() - clkTotal;
// 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 );
+ static char * pLastName = NULL;
+ FILE * pTable = fopen( "fpga/ucsb/stats.txt", "a+" );
+ if ( pLastName == NULL || strcmp(pLastName, p->pName) )
+ {
+ fprintf( pTable, "\n" );
+ fprintf( pTable, "%s ", p->pName );
+
+ fprintf( pTable, "%d ", If_ManCiNum(p) );
+ fprintf( pTable, "%d ", If_ManCoNum(p) );
+ fprintf( pTable, "%d ", If_ManAndNum(p) );
+
+ ABC_FREE( pLastName );
+ pLastName = Abc_UtilStrsav( p->pName );
+ }
+
+ fprintf( pTable, "%d ", (int)p->AreaGlo );
+ fprintf( pTable, "%d ", (int)p->RequiredGlo );
+ fclose( pTable );
}
+*/
return 1;
}
diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c
index 6b058ee7..dbe0e65e 100644
--- a/src/map/if/ifMan.c
+++ b/src/map/if/ifMan.c
@@ -178,6 +178,7 @@ void If_ManStop( If_Man_t * p )
ABC_FREE( p->pHashTable[1] );
if ( p->pMemEntries )
Mem_FixedStop( p->pMemEntries, 0 );
+ ABC_FREE( p->pName );
ABC_FREE( p );
}
diff --git a/src/map/if/ifMap.c b/src/map/if/ifMap.c
index 2e0115ef..e2c2ff0a 100644
--- a/src/map/if/ifMap.c
+++ b/src/map/if/ifMap.c
@@ -155,15 +155,12 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// recompute the parameters of the best cut
/// if ( p->pPars->pLutStruct )
/// pCut->Delay = If_CutDelayLutStruct( p, pCut, p->pPars->pLutStruct, p->pPars->WireDelay );
-// else if ( p->pPars->fDelayOpt )
if ( p->pPars->fUserRecLib )
pCut->Delay = If_CutDelayRecCost(p, pCut, pObj);
else if(p->pPars->fDelayOpt)
- {
-// pCut->Delay = If_CutDelaySopCost(p,pCut);
-// pCut->Delay = If_CutDelaySopCost2(p,pCut);
pCut->Delay = If_CutDelaySopCost(p,pCut);
- }
+ else if(p->pPars->nGateSize > 0)
+ pCut->Delay = If_CutDelaySop(p,pCut);
else
pCut->Delay = If_CutDelay( p, pObj, pCut );
// assert( pCut->Delay <= pObj->Required + p->fEpsilon );
@@ -230,15 +227,12 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// check if the cut satisfies the required times
/// if ( p->pPars->pLutStruct )
/// pCut->Delay = If_CutDelayLutStruct( p, pCut, p->pPars->pLutStruct, p->pPars->WireDelay );
-// else if ( p->pPars->fDelayOpt )
if ( p->pPars->fUserRecLib )
pCut->Delay = If_CutDelayRecCost(p, pCut, pObj);
else if (p->pPars->fDelayOpt)
- {
-// pCut->Delay = If_CutDelaySopCost(p, pCut);
-// pCut->Delay = If_CutDelaySopCost2(p, pCut);
pCut->Delay = If_CutDelaySopCost(p, pCut);
- }
+ else if(p->pPars->nGateSize > 0)
+ pCut->Delay = If_CutDelaySop(p,pCut);
else
pCut->Delay = If_CutDelay( p, pObj, pCut );
//if ( pCut->Cost == IF_COST_MAX )
diff --git a/src/map/if/ifTime.c b/src/map/if/ifTime.c
index 95a856b8..5f7f8142 100644
--- a/src/map/if/ifTime.c
+++ b/src/map/if/ifTime.c
@@ -547,6 +547,75 @@ int If_CutDelaySopCost2( If_Man_t * p, If_Cut_t * pCut )
/**Function*************************************************************
+ Synopsis [Computes the SOP delay using balanced AND decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int If_CutMaxCubeSize( Vec_Int_t * vCover, int nVars )
+{
+ int i, k, Entry, Literal, Count, CountMax = 0;
+ Vec_IntForEachEntry( vCover, Entry, i )
+ {
+ Count = 0;
+ for ( k = 0; k < nVars; k++ )
+ {
+ Literal = (3 & (Entry >> (k << 1)));
+ if ( Literal == 1 || Literal == 2 )
+ Count++;
+ }
+ CountMax = Abc_MaxInt( CountMax, Count );
+ }
+ return CountMax;
+}
+int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut )
+{
+ // delay is calculated using 1+log2(NumFanins)
+ static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
+ If_Obj_t * pLeaf;
+ int Delay, DelayMax;
+ int i, nLitMax, RetValue;
+ // mark cut as a user cut
+ pCut->fUser = 1;
+ if ( p->vCover == NULL )
+ p->vCover = Vec_IntAlloc(0);
+ RetValue = Kit_TruthIsop( If_CutTruth(pCut), If_CutLeaveNum(pCut), p->vCover, 1 );
+ if ( RetValue == -1 )
+ return ABC_INFINITY;
+ assert( RetValue == 0 || RetValue == 1 );
+ // mark the output as complemented
+// vAnds = If_CutDelaySopAnds( p, pCut, p->vCover, RetValue ^ pCut->fCompl );
+ if ( Vec_IntSize(p->vCover) > p->pPars->nGateSize )
+ return ABC_INFINITY;
+ // set the area cost
+ assert( If_CutLeaveNum(pCut) >= 0 && If_CutLeaveNum(pCut) <= 16 );
+ // compute the gate delay
+ nLitMax = If_CutMaxCubeSize( p->vCover, If_CutLeaveNum(pCut) );
+ if ( Vec_IntSize(p->vCover) < 2 )
+ {
+ pCut->Cost = Vec_IntSize(p->vCover);
+ Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + 0.5);
+ DelayMax = 0;
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pCut->pPerm[i] = (char)Delay) );
+ }
+ else
+ {
+ pCut->Cost = Vec_IntSize(p->vCover) + 1;
+ Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + GateDelays[nLitMax] + 0.5);
+ DelayMax = 0;
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pCut->pPerm[i] = (char)Delay) );
+ }
+ return DelayMax;
+}
+
+/**Function*************************************************************
+
Synopsis [Computes delay.]
Description []