Commit 60c66148 by Alan Mishchenko

Extending Genlib to hangle multi-output cells.

parent 48996f7a
...@@ -88,6 +88,7 @@ struct Mio_GateStruct_t_ ...@@ -88,6 +88,7 @@ struct Mio_GateStruct_t_
Mio_Library_t * pLib; Mio_Library_t * pLib;
// the next gate in the list // the next gate in the list
Mio_Gate_t * pNext; Mio_Gate_t * pNext;
Mio_Gate_t * pTwin;
// the derived information // the derived information
int nInputs; // the number of inputs int nInputs; // the number of inputs
......
...@@ -232,7 +232,12 @@ int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtended ...@@ -232,7 +232,12 @@ int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtended
if ( !st_is_member( pLib->tName2Gate, pGate->pName ) ) if ( !st_is_member( pLib->tName2Gate, pGate->pName ) )
st_insert( pLib->tName2Gate, pGate->pName, (char *)pGate ); st_insert( pLib->tName2Gate, pGate->pName, (char *)pGate );
else else
printf( "The gate with name \"%s\" appears more than once.\n", pGate->pName ); {
Mio_Gate_t * pBase = Mio_LibraryReadGateByName( pLib, pGate->pName );
pBase->pTwin = pGate;
pGate->pTwin = pBase;
printf( "Gate \"%s\" appears more than once. Creating multi-output gate.\n", pGate->pName );
}
} }
} }
if ( fVerbose ) if ( fVerbose )
......
...@@ -28,10 +28,6 @@ ABC_NAMESPACE_IMPL_START ...@@ -28,10 +28,6 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int fPrintSops );
static void Mio_WritePin( FILE * pFile, Mio_Pin_t * pPin );
static int Mio_DelayCompare( Mio_Gate_t ** ppG1, Mio_Gate_t ** ppG2 );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -141,7 +137,7 @@ Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin ) ...@@ -141,7 +137,7 @@ Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin )
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis [Check if pin characteristics are the same.]
Description [] Description []
...@@ -150,16 +146,23 @@ Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin ) ...@@ -150,16 +146,23 @@ Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops ) int Mio_CheckPins( Mio_Pin_t * pPin1, Mio_Pin_t * pPin2 )
{ {
// Mio_Gate_t * pGate; if ( pPin1 == NULL || pPin2 == NULL )
int i; return 1;
if ( pPin1->dLoadInput != pPin2->dLoadInput )
fprintf( pFile, "# The genlib library \"%s\".\n", pLib->pName ); return 0;
// Mio_LibraryForEachGate( pLib, pGate ) if ( pPin1->dLoadMax != pPin2->dLoadMax )
// Mio_WriteGate( pFile, pGate, fPrintSops ); return 0;
for ( i = 0; i < pLib->nGates; i++ ) if ( pPin1->dDelayBlockRise != pPin2->dDelayBlockRise )
Mio_WriteGate( pFile, pLib->ppGates0[i], fPrintSops ); return 0;
if ( pPin1->dDelayFanoutRise != pPin2->dDelayFanoutRise )
return 0;
if ( pPin1->dDelayBlockFall != pPin2->dDelayBlockFall )
return 0;
if ( pPin1->dDelayFanoutFall != pPin2->dDelayFanoutFall )
return 0;
return 1;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -173,21 +176,57 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops ) ...@@ -173,21 +176,57 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int fPrintSops ) void Mio_WritePin( FILE * pFile, Mio_Pin_t * pPin, int NameLen, int fAllPins )
{ {
Mio_Pin_t * pPin; char * pPhaseNames[10] = { "UNKNOWN", "INV", "NONINV" };
if ( fAllPins )
fprintf( pFile, "PIN * " );
else
fprintf( pFile, "\n PIN %*s ", NameLen, pPin->pName );
fprintf( pFile, "%7s ", pPhaseNames[pPin->Phase] );
fprintf( pFile, "%3d ", (int)pPin->dLoadInput );
fprintf( pFile, "%3d ", (int)pPin->dLoadMax );
fprintf( pFile, "%6.2f ", pPin->dDelayBlockRise );
fprintf( pFile, "%6.2f ", pPin->dDelayFanoutRise );
fprintf( pFile, "%6.2f ", pPin->dDelayBlockFall );
fprintf( pFile, "%6.2f", pPin->dDelayFanoutFall );
}
fprintf( pFile, "GATE " ); /**Function*************************************************************
fprintf( pFile, "%12s ", pGate->pName );
fprintf( pFile, "%10.2f ", pGate->dArea ); Synopsis []
fprintf( pFile, "%s=%s;\n", pGate->pOutName, pGate->pForm );
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int GateLen, int NameLen, int FormLen, int fPrintSops )
{
char Buffer[5000];
Mio_Pin_t * pPin = NULL, * pPin0 = NULL;
assert( NameLen+FormLen+2 < 5000 );
sprintf( Buffer, "%s=%s;", pGate->pOutName, pGate->pForm );
fprintf( pFile, "GATE %-*s ", GateLen, pGate->pName );
fprintf( pFile, "%8.2f ", pGate->dArea );
fprintf( pFile, "%-*s ", NameLen+FormLen+2, Buffer );
// compare pins and decide if their properties are the same
Mio_GateForEachPin( pGate, pPin )
if ( Mio_CheckPins( pPin0, pPin ) )
pPin0 = pPin;
else
break;
// print the pins // print the pins
if ( fPrintSops ) if ( fPrintSops )
fprintf( pFile, "%s", pGate->pSop? pGate->pSop : "unspecified\n" ); fprintf( pFile, "%s", pGate->pSop? pGate->pSop : "unspecified\n" );
// Extra_bddPrint( pGate->pLib->dd, pGate->bFunc ); if ( pPin != NULL ) // different pins
// fprintf( pFile, "\n" );
Mio_GateForEachPin( pGate, pPin ) Mio_GateForEachPin( pGate, pPin )
Mio_WritePin( pFile, pPin ); Mio_WritePin( pFile, pPin, NameLen, 0 );
else if ( pPin0 != NULL ) // equal pins
Mio_WritePin( pFile, pPin0, NameLen, 1 );
fprintf( pFile, "\n" );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -201,19 +240,42 @@ void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int fPrintSops ) ...@@ -201,19 +240,42 @@ void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int fPrintSops )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Mio_WritePin( FILE * pFile, Mio_Pin_t * pPin ) void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops )
{ {
char * pPhaseNames[10] = { "UNKNOWN", "INV", "NONINV" }; Mio_Gate_t * pGate;
fprintf( pFile, " PIN " ); Mio_Pin_t * pPin;
fprintf( pFile, "%9s ", pPin->pName ); int i, GateLen = 0, NameLen = 0, FormLen = 0;
fprintf( pFile, "%10s ", pPhaseNames[pPin->Phase] ); Mio_LibraryForEachGate( pLib, pGate )
fprintf( pFile, "%6d ", (int)pPin->dLoadInput ); {
fprintf( pFile, "%6d ", (int)pPin->dLoadMax ); GateLen = Abc_MaxInt( GateLen, strlen(pGate->pName) );
fprintf( pFile, "%6.2f ", pPin->dDelayBlockRise ); NameLen = Abc_MaxInt( NameLen, strlen(pGate->pOutName) );
fprintf( pFile, "%6.2f ", pPin->dDelayFanoutRise ); FormLen = Abc_MaxInt( FormLen, strlen(pGate->pForm) );
fprintf( pFile, "%6.2f ", pPin->dDelayBlockFall ); Mio_GateForEachPin( pGate, pPin )
fprintf( pFile, "%6.2f", pPin->dDelayFanoutFall ); NameLen = Abc_MaxInt( NameLen, strlen(pPin->pName) );
fprintf( pFile, "\n" ); }
fprintf( pFile, "# The genlib library \"%s\".\n", pLib->pName );
for ( i = 0; i < pLib->nGates; i++ )
Mio_WriteGate( pFile, pLib->ppGates0[i], GateLen, NameLen, FormLen, fPrintSops );
}
/**Function*************************************************************
Synopsis [Compares the max delay of two gates.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mio_DelayCompare( Mio_Gate_t ** ppG1, Mio_Gate_t ** ppG2 )
{
if ( (*ppG1)->dDelayMax < (*ppG2)->dDelayMax )
return -1;
if ( (*ppG1)->dDelayMax > (*ppG2)->dDelayMax )
return 1;
return 0;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -278,26 +340,6 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, ...@@ -278,26 +340,6 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay,
/**Function************************************************************* /**Function*************************************************************
Synopsis [Compares the max delay of two gates.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mio_DelayCompare( Mio_Gate_t ** ppG1, Mio_Gate_t ** ppG2 )
{
if ( (*ppG1)->dDelayMax < (*ppG2)->dDelayMax )
return -1;
if ( (*ppG1)->dDelayMax > (*ppG2)->dDelayMax )
return 1;
return 0;
}
/**Function*************************************************************
Synopsis [Derives the truth table of the gate.] Synopsis [Derives the truth table of the gate.]
Description [] Description []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment