summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-07-25 20:02:56 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-07-25 20:02:56 -0700
commit7d81490fe66c0deda91ef04be6d1f79be7025c6a (patch)
treeeca04b4414d77d187cd81e0638569e66c9010069
parent9bfe2ad73aaa4d03bb1273950f873e3adb83fb29 (diff)
downloadabc-7d81490fe66c0deda91ef04be6d1f79be7025c6a.tar.gz
abc-7d81490fe66c0deda91ef04be6d1f79be7025c6a.tar.bz2
abc-7d81490fe66c0deda91ef04be6d1f79be7025c6a.zip
Generating abstraction of standard cell library.
-rw-r--r--src/aig/gia/giaLf.c4
-rw-r--r--src/base/abci/abc.c23
-rw-r--r--src/map/mio/exp.h2
-rw-r--r--src/map/mio/mio.h13
-rw-r--r--src/map/mio/mioForm.c2
-rw-r--r--src/map/mio/mioFunc.c4
-rw-r--r--src/map/mio/mioRead.c8
-rw-r--r--src/map/mio/mioUtils.c144
8 files changed, 181 insertions, 19 deletions
diff --git a/src/aig/gia/giaLf.c b/src/aig/gia/giaLf.c
index 96a633f4..5b0440af 100644
--- a/src/aig/gia/giaLf.c
+++ b/src/aig/gia/giaLf.c
@@ -52,6 +52,10 @@ Gia_Man_t * Lf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
{
return Jf_ManPerformMapping( pGia, pPars );
}
+Gia_Man_t * Gia_ManPerformLfMapping( Gia_Man_t * p, Jf_Par_t * pPars, int fNormalized )
+{
+ return NULL;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 6c618cce..6bec3157 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -10595,19 +10595,24 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
Bmc_EcoMiterTest();
}
*/
+
+ {
+// extern void Nf_ManPrepareLibraryTest();
+// Nf_ManPrepareLibraryTest();
+// return 0;
+ }
+
if ( pNtk )
{
extern Abc_Ntk_t * Abc_NtkBarBufsOnOffTest( Abc_Ntk_t * pNtk );
Abc_Ntk_t * pNtkRes = Abc_NtkBarBufsOnOffTest( pNtk );
-/*
- extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fNewAlgo, int fVerbose );
- extern Abc_Ntk_t * Abc_NtkPcmTestAig( Abc_Ntk_t * pNtk, int fVerbose );
- Abc_Ntk_t * pNtkRes;
- if ( Abc_NtkIsLogic(pNtk) )
- pNtkRes = Abc_NtkPcmTest( pNtk, fNewAlgo, fVerbose );
- else
- pNtkRes = Abc_NtkPcmTestAig( pNtk, fVerbose );
-*/
+// extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fNewAlgo, int fVerbose );
+// extern Abc_Ntk_t * Abc_NtkPcmTestAig( Abc_Ntk_t * pNtk, int fVerbose );
+// Abc_Ntk_t * pNtkRes;
+// if ( Abc_NtkIsLogic(pNtk) )
+// pNtkRes = Abc_NtkPcmTest( pNtk, fNewAlgo, fVerbose );
+// else
+// pNtkRes = Abc_NtkPcmTestAig( pNtk, fVerbose );
if ( pNtkRes == NULL )
{
Abc_Print( -1, "Command has failed.\n" );
diff --git a/src/map/mio/exp.h b/src/map/mio/exp.h
index 73a8f683..1e14b1bd 100644
--- a/src/map/mio/exp.h
+++ b/src/map/mio/exp.h
@@ -175,7 +175,7 @@ static inline word Exp_Truth6Lit( int nVars, int Lit, word * puFanins, word * pu
if ( Lit == EXP_CONST0 )
return 0;
if ( Lit == EXP_CONST1 )
- return ~0;
+ return ~(word)0;
if ( Lit < 2 * nVars )
return (Lit&1) ? ~puFanins[Lit/2] : puFanins[Lit/2];
return (Lit&1) ? ~puNodes[Lit/2-nVars] : puNodes[Lit/2-nVars];
diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h
index c7d90917..7c3aa396 100644
--- a/src/map/mio/mio.h
+++ b/src/map/mio/mio.h
@@ -43,7 +43,16 @@ typedef struct Mio_LibraryStruct_t_ Mio_Library_t;
typedef struct Mio_GateStruct_t_ Mio_Gate_t;
typedef struct Mio_PinStruct_t_ Mio_Pin_t;
-static inline char * Mio_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; }
+typedef struct Mio_Cell_t_ Mio_Cell_t;
+struct Mio_Cell_t_
+{
+ char * pName; // name
+ word uTruth; // truth table
+ float Area; // area
+ unsigned Id : 28; // gate ID
+ unsigned nFanins : 4; // gate fanins
+ float Delays[6]; // delay
+};
////////////////////////////////////////////////////////////////////////
/// GLOBAL VARIABLES ///
@@ -151,6 +160,8 @@ extern void Mio_PinDelete( Mio_Pin_t * pPin );
extern Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin );
extern void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops );
extern Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, int fSkipInv, int * pnGates, int fVerbose );
+extern Mio_Cell_t * Mio_CollectRootsNew( Mio_Library_t * pLib, int nInputs, int * pnGates, int fVerbose );
+extern Mio_Cell_t * Mio_CollectRootsNewDefault( int nInputs, int * pnGates, int fVerbose );
extern word Mio_DeriveTruthTable6( Mio_Gate_t * pGate );
extern void Mio_DeriveTruthTable( Mio_Gate_t * pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[] );
extern void Mio_DeriveGateDelays( Mio_Gate_t * pGate,
diff --git a/src/map/mio/mioForm.c b/src/map/mio/mioForm.c
index b3b962c0..9c62212d 100644
--- a/src/map/mio/mioForm.c
+++ b/src/map/mio/mioForm.c
@@ -290,7 +290,7 @@ int Mio_GateCollectNames( char * pFormula, char * pPinNames[] )
break;
if ( i == nPins )
{ // cannot find this name; save it
- pPinNames[nPins++] = Mio_UtilStrsav(pTemp);
+ pPinNames[nPins++] = Abc_UtilStrsav(pTemp);
}
// get the next name
pTemp = strtok( NULL, " " );
diff --git a/src/map/mio/mioFunc.c b/src/map/mio/mioFunc.c
index 67126749..59df45f5 100644
--- a/src/map/mio/mioFunc.c
+++ b/src/map/mio/mioFunc.c
@@ -101,7 +101,7 @@ int Mio_GateCollectNames( char * pFormula, char * pPinNames[] )
break;
if ( i == nPins )
{ // cannot find this name; save it
- pPinNames[nPins++] = Mio_UtilStrsav(pTemp);
+ pPinNames[nPins++] = Abc_UtilStrsav(pTemp);
}
// get the next name
pTemp = strtok( NULL, " " );
@@ -147,6 +147,7 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate )
// pGate->bFunc = b0;
pGate->vExpr = Exp_Const0();
pGate->pSop = Mio_SopRegister( (Mem_Flex_t *)pGate->pLib->pMmFlex, " 0\n" );
+ pGate->uTruth = 0;
pGate->pLib->pGate0 = pGate;
}
else if ( strcmp( pGate->pForm, MIO_STRING_CONST1 ) == 0 )
@@ -154,6 +155,7 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate )
// pGate->bFunc = b1;
pGate->vExpr = Exp_Const1();
pGate->pSop = Mio_SopRegister( (Mem_Flex_t *)pGate->pLib->pMmFlex, " 1\n" );
+ pGate->uTruth = ~(word)0;
pGate->pLib->pGate1 = pGate;
}
else
diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c
index 860ce39c..b5b334da 100644
--- a/src/map/mio/mioRead.c
+++ b/src/map/mio/mioRead.c
@@ -207,7 +207,7 @@ Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st__ta
pLib = Mio_LibraryReadBuffer( pBuffer, fExtendedFormat, tExcludeGate, fVerbose );
ABC_FREE( pBuffer );
if ( pLib )
- pLib->pName = Mio_UtilStrsav( FileName );
+ pLib->pName = Abc_UtilStrsav( FileName );
return pLib;
}
@@ -340,7 +340,7 @@ Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat )
// read the name
pToken = strtok( NULL, " \t\r\n" );
- pGate->pName = Mio_UtilStrsav( pToken );
+ pGate->pName = Abc_UtilStrsav( pToken );
// read the area
pToken = strtok( NULL, " \t\r\n" );
@@ -407,7 +407,7 @@ Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, int fExtendedFormat )
// read the name
pToken = strtok( NULL, " \t\r\n" );
- pPin->pName = Mio_UtilStrsav( pToken );
+ pPin->pName = Abc_UtilStrsav( pToken );
// read the pin phase
pToken = strtok( NULL, " \t\r\n" );
@@ -672,7 +672,7 @@ int Mio_LibraryReadExclude( char * ExcludeFile, st__table * tExcludeGate )
while (1 == fscanf( pEx, "%127s", buffer ))
{
//printf ("Read: '%s'\n", buffer );
- st__insert( tExcludeGate, Mio_UtilStrsav( buffer ), (char *)0 );
+ st__insert( tExcludeGate, Abc_UtilStrsav( buffer ), (char *)0 );
nDel++;
}
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index 781db6c0..21b61d75 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -126,7 +126,7 @@ Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin )
pPinNew = ABC_ALLOC( Mio_Pin_t, 1 );
*pPinNew = *pPin;
- pPinNew->pName = (pPinNew->pName ? Mio_UtilStrsav(pPinNew->pName) : NULL);
+ pPinNew->pName = (pPinNew->pName ? Abc_UtilStrsav(pPinNew->pName) : NULL);
pPinNew->pNext = NULL;
return pPinNew;
@@ -313,7 +313,7 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay,
continue;
if ( tDelay > 0.0 && pGate->dDelayMax > (double)tDelay )
continue;
- if ( pGate->uTruth == 0 || pGate->uTruth == ~0 )
+ if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
continue;
if ( pGate->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) )
continue;
@@ -350,6 +350,146 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay,
return ppGates;
}
+
+/**Function*************************************************************
+
+ Synopsis [Compares the max delay of two gates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Mio_DelayCompareNew( Mio_Cell_t * pG1, Mio_Cell_t * pG2 )
+{
+ if ( (pG1)->nFanins < (pG2)->nFanins )
+ return -1;
+ if ( (pG1)->nFanins > (pG2)->nFanins )
+ return 1;
+ if ( (pG1)->Area < (pG2)->Area )
+ return -1;
+ if ( (pG1)->Area > (pG2)->Area )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the set of root gates.]
+
+ Description [Only collects the gates with unique functionality,
+ which have fewer inputs and shorter delay than the given limits.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Mio_CollectCopy( Mio_Cell_t * pCell, Mio_Gate_t * pGate )
+{
+ Mio_Pin_t * pPin;
+ int k;
+ pCell->pName = pGate->pName;
+ pCell->uTruth = pGate->uTruth;
+ pCell->Area = (float)pGate->dArea;
+ pCell->nFanins = pGate->nInputs;
+ for ( k = 0, pPin = pGate->pPins; pPin; pPin = pPin->pNext, k++ )
+ pCell->Delays[k] = (float)(0.5 * pPin->dDelayBlockRise + 0.5 * pPin->dDelayBlockFall);
+}
+
+Mio_Cell_t * Mio_CollectRootsNew( Mio_Library_t * pLib, int nInputs, int * pnGates, int fVerbose )
+{
+ Mio_Gate_t * pGate;
+ Mio_Cell_t * ppCells;
+ int i, nGates, iCell = 4;
+ nGates = Mio_LibraryReadGateNum( pLib );
+ ppCells = ABC_CALLOC( Mio_Cell_t, nGates + 4 );
+ // for each functionality, select gate with the smallest area
+ // if equal areas, select gate with lexicographically smaller name
+ Mio_LibraryForEachGate( pLib, pGate )
+ {
+ if ( pGate->nInputs > nInputs || pGate->pTwin ) // skip large and multi-output
+ continue;
+ // check if the gate with this functionality already exists
+ for ( i = 0; i < iCell; i++ )
+ if ( ppCells[i].pName && ppCells[i].uTruth == pGate->uTruth )
+ {
+ if ( ppCells[i].Area > pGate->dArea ||
+ (ppCells[i].Area == pGate->dArea && strcmp(ppCells[i].pName, pGate->pName) > 0) )
+ {
+ Mio_CollectCopy( ppCells + i, pGate );
+ }
+ break;
+ }
+ if ( i < iCell )
+ continue;
+ if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
+ {
+ int Idx = (int)(pGate->uTruth == ~(word)0);
+ assert( pGate->nInputs == 0 );
+ Mio_CollectCopy( ppCells + Idx, pGate );
+ continue;
+ }
+ if ( pGate->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) || pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA) )
+ {
+ int Idx = 2 + (int)(pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA));
+ assert( pGate->nInputs == 1 );
+ Mio_CollectCopy( ppCells + Idx, pGate );
+ continue;
+ }
+ Mio_CollectCopy( ppCells + iCell++, pGate );
+ }
+ // sort by delay
+ if ( iCell > 1 )
+ {
+ qsort( (void *)(ppCells + 4), iCell - 4, sizeof(Mio_Cell_t),
+ (int (*)(const void *, const void *)) Mio_DelayCompareNew );
+ assert( Mio_DelayCompareNew( ppCells + 4, ppCells + iCell - 1 ) <= 0 );
+ }
+ // assign IDs
+ for ( i = 0; i < iCell; i++ )
+ ppCells[i].Id = ppCells[i].pName ? i : -1;
+
+ // report
+ if ( fVerbose )
+ {
+ // count gates
+ int * pCounts = ABC_CALLOC( int, nGates + 4 );
+ Mio_LibraryForEachGate( pLib, pGate )
+ {
+ if ( pGate->nInputs > nInputs || pGate->pTwin ) // skip large and multi-output
+ continue;
+ for ( i = 0; i < iCell; i++ )
+ if ( ppCells[i].pName && ppCells[i].uTruth == pGate->uTruth )
+ {
+ pCounts[i]++;
+ break;
+ }
+ assert( i < iCell );
+ }
+ for ( i = 0; i < iCell; i++ )
+ {
+ Mio_Cell_t * pCell = ppCells + i;
+ printf( "%4d : ", i );
+ if ( pCell->pName == NULL )
+ printf( "None\n" );
+ else
+ printf( "%-20s In = %d N = %3d A = %7.2f D = %7.2f\n",
+ pCell->pName, pCell->nFanins, pCounts[i], pCell->Area, pCell->Delays[0] );
+ }
+ ABC_FREE( pCounts );
+ }
+ if ( pnGates )
+ *pnGates = iCell;
+ return ppCells;
+}
+Mio_Cell_t * Mio_CollectRootsNewDefault( int nInputs, int * pnGates, int fVerbose )
+{
+ return Mio_CollectRootsNew( (Mio_Library_t *)Abc_FrameReadLibGen(), nInputs, pnGates, fVerbose );
+}
+
/**Function*************************************************************
Synopsis [Derives the truth table of the gate.]