summaryrefslogtreecommitdiffstats
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mapper/mapperSuper.c2
-rw-r--r--src/map/mapper/mapperTree.c2
-rw-r--r--src/map/mapper/mapperTree_old.c2
-rw-r--r--src/map/mio/mio.h9
-rw-r--r--src/map/mio/mioApi.c25
-rw-r--r--src/map/mio/mioRead.c13
-rw-r--r--src/map/mio/mioUtils.c35
-rw-r--r--src/map/scl/sclUtil.c2
8 files changed, 54 insertions, 36 deletions
diff --git a/src/map/mapper/mapperSuper.c b/src/map/mapper/mapperSuper.c
index efcb90ea..bf351a54 100644
--- a/src/map/mapper/mapperSuper.c
+++ b/src/map/mapper/mapperSuper.c
@@ -382,7 +382,7 @@ void Map_LibraryComputeTruth_rec( Map_SuperLib_t * pLib, char * pFormula, unsign
for ( i = 0; i < nStrings; i++ )
Map_LibraryComputeTruth_rec( pLib, pStrings[i], uTruthsIn, uTruthsFanins[i] );
// get the root supergate
- pMioGate = Mio_LibraryReadGateByName( pLib->pGenlib, pGateName );
+ pMioGate = Mio_LibraryReadGateByName( pLib->pGenlib, pGateName, NULL );
if ( pMioGate == NULL )
printf( "A supergate contains gate \"%s\" that is not in \"%s\".\n", pGateName, Mio_LibraryReadName(pLib->pGenlib) );
// derive the functionality of the output of the supergate
diff --git a/src/map/mapper/mapperTree.c b/src/map/mapper/mapperTree.c
index 2244fa26..36ad4920 100644
--- a/src/map/mapper/mapperTree.c
+++ b/src/map/mapper/mapperTree.c
@@ -302,7 +302,7 @@ Map_Super_t * Map_LibraryReadGateTree( Map_SuperLib_t * pLib, char * pBuffer, in
}
// read the root gate
- pGate->pRoot = Mio_LibraryReadGateByName( pLib->pGenlib, pTemp );
+ pGate->pRoot = Mio_LibraryReadGateByName( pLib->pGenlib, pTemp, NULL );
if ( pGate->pRoot == NULL )
{
printf( "Cannot read the root gate names %s.\n", pTemp );
diff --git a/src/map/mapper/mapperTree_old.c b/src/map/mapper/mapperTree_old.c
index 1a76b267..eafba376 100644
--- a/src/map/mapper/mapperTree_old.c
+++ b/src/map/mapper/mapperTree_old.c
@@ -299,7 +299,7 @@ Map_Super_t * Map_LibraryReadGateTree( Map_SuperLib_t * pLib, char * pBuffer, in
}
// read the root gate
- pGate->pRoot = Mio_LibraryReadGateByName( pLib->pGenlib, pTemp );
+ pGate->pRoot = Mio_LibraryReadGateByName( pLib->pGenlib, pTemp, NULL );
if ( pGate->pRoot == NULL )
{
printf( "Cannot read the root gate names %s.\n", pTemp );
diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h
index 7bccc3a1..3aff8790 100644
--- a/src/map/mio/mio.h
+++ b/src/map/mio/mio.h
@@ -68,8 +68,8 @@ static inline char * Mio_UtilStrsav( char * s ) { return s ? strcpy(ABC_A
for ( Pin = Mio_GateReadPins(Gate); \
Pin; \
Pin = Mio_PinReadNext(Pin) )
-#define Mio_GateForEachPinSafe( Gate, Pin, Pin2 ) \
- for ( Pin = Mio_GateReadPins(Gate), \
+#define Mio_GateForEachPinSafe( Gate, Pin, Pin2 ) \
+ for ( Pin = Mio_GateReadPins(Gate), \
Pin2 = (Pin? Mio_PinReadNext(Pin): NULL); \
Pin; \
Pin = Pin2, \
@@ -83,8 +83,8 @@ static inline char * Mio_UtilStrsav( char * s ) { return s ? strcpy(ABC_A
extern char * Mio_LibraryReadName ( Mio_Library_t * pLib );
extern int Mio_LibraryReadGateNum ( Mio_Library_t * pLib );
extern Mio_Gate_t * Mio_LibraryReadGates ( Mio_Library_t * pLib );
-extern Mio_Gate_t ** Mio_LibraryReadGatesByName( Mio_Library_t * pLib );
-extern Mio_Gate_t * Mio_LibraryReadGateByName ( Mio_Library_t * pLib, char * pName );
+extern Mio_Gate_t ** Mio_LibraryReadGateArray ( Mio_Library_t * pLib );
+extern Mio_Gate_t * Mio_LibraryReadGateByName ( Mio_Library_t * pLib, char * pName, char * pOutName );
extern char * Mio_LibraryReadSopByName ( Mio_Library_t * pLib, char * pName );
extern Mio_Gate_t * Mio_LibraryReadConst0 ( Mio_Library_t * pLib );
extern Mio_Gate_t * Mio_LibraryReadConst1 ( Mio_Library_t * pLib );
@@ -110,6 +110,7 @@ extern char * Mio_GateReadForm ( Mio_Gate_t * pGate );
extern Mio_Pin_t * Mio_GateReadPins ( Mio_Gate_t * pGate );
extern Mio_Library_t * Mio_GateReadLib ( Mio_Gate_t * pGate );
extern Mio_Gate_t * Mio_GateReadNext ( Mio_Gate_t * pGate );
+extern Mio_Gate_t * Mio_GateReadTwin ( Mio_Gate_t * pGate );
extern int Mio_GateReadInputs ( Mio_Gate_t * pGate );
extern double Mio_GateReadDelayMax ( Mio_Gate_t * pGate );
extern char * Mio_GateReadSop ( Mio_Gate_t * pGate );
diff --git a/src/map/mio/mioApi.c b/src/map/mio/mioApi.c
index d2357e7d..2fe23c2c 100644
--- a/src/map/mio/mioApi.c
+++ b/src/map/mio/mioApi.c
@@ -40,13 +40,12 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
-char * Mio_LibraryReadName ( Mio_Library_t * pLib ) { return pLib->pName; }
-int Mio_LibraryReadGateNum ( Mio_Library_t * pLib ) { return pLib->nGates; }
-Mio_Gate_t * Mio_LibraryReadGates ( Mio_Library_t * pLib ) { return pLib->pGates; }
-Mio_Gate_t ** Mio_LibraryReadGatesByName ( Mio_Library_t * pLib ) { return pLib->ppGatesName;}
-//DdManager * Mio_LibraryReadDd ( Mio_Library_t * pLib ) { return pLib->dd; }
-Mio_Gate_t * Mio_LibraryReadBuf ( Mio_Library_t * pLib ) { return pLib->pGateBuf; }
-Mio_Gate_t * Mio_LibraryReadInv ( Mio_Library_t * pLib ) { return pLib->pGateInv; }
+char * Mio_LibraryReadName ( Mio_Library_t * pLib ) { return pLib->pName; }
+int Mio_LibraryReadGateNum ( Mio_Library_t * pLib ) { return pLib->nGates; }
+Mio_Gate_t * Mio_LibraryReadGates ( Mio_Library_t * pLib ) { return pLib->pGates; }
+Mio_Gate_t ** Mio_LibraryReadGateArray ( Mio_Library_t * pLib ) { return pLib->ppGatesName;}
+Mio_Gate_t * Mio_LibraryReadBuf ( Mio_Library_t * pLib ) { return pLib->pGateBuf; }
+Mio_Gate_t * Mio_LibraryReadInv ( Mio_Library_t * pLib ) { return pLib->pGateInv; }
Mio_Gate_t * Mio_LibraryReadConst0 ( Mio_Library_t * pLib ) { return pLib->pGate0; }
Mio_Gate_t * Mio_LibraryReadConst1 ( Mio_Library_t * pLib ) { return pLib->pGate1; }
Mio_Gate_t * Mio_LibraryReadNand2 ( Mio_Library_t * pLib ) { return pLib->pGateNand2; }
@@ -97,11 +96,17 @@ int Mio_LibraryReadGateNameMax( Mio_Library_t * pLib )
SeeAlso []
***********************************************************************/
-Mio_Gate_t * Mio_LibraryReadGateByName( Mio_Library_t * pLib, char * pName )
+Mio_Gate_t * Mio_LibraryReadGateByName( Mio_Library_t * pLib, char * pName, char * pOutName )
{
Mio_Gate_t * pGate;
- if ( st_lookup( pLib->tName2Gate, pName, (char **)&pGate ) )
+ if ( !st_lookup( pLib->tName2Gate, pName, (char **)&pGate ) )
+ return NULL;
+ if ( pOutName == NULL )
+ return pGate;
+ if ( !strcmp(pGate->pOutName, pOutName) )
return pGate;
+ if ( pGate->pTwin && !strcmp(pGate->pTwin->pOutName, pOutName) )
+ return pGate->pTwin;
return NULL;
}
@@ -142,10 +147,10 @@ char * Mio_GateReadForm ( Mio_Gate_t * pGate ) { return
Mio_Pin_t * Mio_GateReadPins ( Mio_Gate_t * pGate ) { return pGate->pPins; }
Mio_Library_t * Mio_GateReadLib ( Mio_Gate_t * pGate ) { return pGate->pLib; }
Mio_Gate_t * Mio_GateReadNext ( Mio_Gate_t * pGate ) { return pGate->pNext; }
+Mio_Gate_t * Mio_GateReadTwin ( Mio_Gate_t * pGate ) { return pGate->pTwin; }
int Mio_GateReadInputs ( Mio_Gate_t * pGate ) { return pGate->nInputs; }
double Mio_GateReadDelayMax( Mio_Gate_t * pGate ) { return pGate->dDelayMax; }
char * Mio_GateReadSop ( Mio_Gate_t * pGate ) { return pGate->pSop; }
-//DdNode * Mio_GateReadFunc ( Mio_Gate_t * pGate ) { return pGate->bFunc; }
word Mio_GateReadTruth ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? pGate->uTruth : 0; }
word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? NULL: pGate->pTruth; }
int Mio_GateReadValue ( Mio_Gate_t * pGate ) { return pGate->Value; }
diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c
index 87fb68e2..53ea7d2d 100644
--- a/src/map/mio/mioRead.c
+++ b/src/map/mio/mioRead.c
@@ -233,10 +233,15 @@ int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtended
st_insert( pLib->tName2Gate, pGate->pName, (char *)pGate );
else
{
- 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 );
+ Mio_Gate_t * pBase = Mio_LibraryReadGateByName( pLib, pGate->pName, NULL );
+ if ( pBase->pTwin != NULL )
+ {
+ printf( "Gates with more than 2 outputs are not supported.\n" );
+ continue;
+ }
+ pBase->pTwin = pGate;
+ pGate->pTwin = pBase;
+ printf( "Gate \"%s\" appears two times. Creating a 2-output gate.\n", pGate->pName );
}
}
}
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index fcc59dcc..41b03d7d 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -164,6 +164,18 @@ int Mio_CheckPins( Mio_Pin_t * pPin1, Mio_Pin_t * pPin2 )
return 0;
return 1;
}
+int Mio_CheckGates( Mio_Library_t * pLib )
+{
+ Mio_Gate_t * pGate;
+ Mio_Pin_t * pPin0 = NULL, * pPin = NULL;
+ Mio_LibraryForEachGate( pLib, pGate )
+ Mio_GateForEachPin( pGate, pPin )
+ if ( Mio_CheckPins( pPin0, pPin ) )
+ pPin0 = pPin;
+ else
+ return 0;
+ return 1;
+}
/**Function*************************************************************
@@ -182,7 +194,7 @@ void Mio_WritePin( FILE * pFile, Mio_Pin_t * pPin, int NameLen, int fAllPins )
if ( fAllPins )
fprintf( pFile, "PIN * " );
else
- fprintf( pFile, "\n PIN %*s ", NameLen, pPin->pName );
+ 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 );
@@ -203,29 +215,23 @@ void Mio_WritePin( FILE * pFile, Mio_Pin_t * pPin, int NameLen, int fAllPins )
SeeAlso []
***********************************************************************/
-void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int GateLen, int NameLen, int FormLen, int fPrintSops )
+void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int GateLen, int NameLen, int FormLen, int fPrintSops, int fAllPins )
{
char Buffer[5000];
- Mio_Pin_t * pPin = NULL, * pPin0 = NULL;
+ Mio_Pin_t * pPin;
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;
+ fprintf( pFile, "%-*s ", Abc_MinInt(NameLen+FormLen+2, 30), Buffer );
// print the pins
if ( fPrintSops )
fprintf( pFile, "%s", pGate->pSop? pGate->pSop : "unspecified\n" );
- if ( pPin != NULL ) // different pins
+ if ( fAllPins && pGate->pPins ) // equal pins
+ Mio_WritePin( pFile, pGate->pPins, NameLen, 1 );
+ else // different pins
Mio_GateForEachPin( pGate, pPin )
Mio_WritePin( pFile, pPin, NameLen, 0 );
- else if ( pPin0 != NULL ) // equal pins
- Mio_WritePin( pFile, pPin0, NameLen, 1 );
fprintf( pFile, "\n" );
}
@@ -245,6 +251,7 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops )
Mio_Gate_t * pGate;
Mio_Pin_t * pPin;
int i, GateLen = 0, NameLen = 0, FormLen = 0;
+ int fAllPins = Mio_CheckGates( pLib );
Mio_LibraryForEachGate( pLib, pGate )
{
GateLen = Abc_MaxInt( GateLen, strlen(pGate->pName) );
@@ -255,7 +262,7 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops )
}
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 );
+ Mio_WriteGate( pFile, pLib->ppGates0[i], GateLen, NameLen, FormLen, fPrintSops, fAllPins );
}
/**Function*************************************************************
diff --git a/src/map/scl/sclUtil.c b/src/map/scl/sclUtil.c
index a9b94902..dc513d56 100644
--- a/src/map/scl/sclUtil.c
+++ b/src/map/scl/sclUtil.c
@@ -232,7 +232,7 @@ void Abc_SclManSetGates( SC_Lib * pLib, Abc_Ntk_t * p, Vec_Int_t * vGates )
{
SC_Cell * pCell = SC_LibCell( pLib, Vec_IntEntry(vGates, Abc_ObjId(pObj)) );
assert( pCell->n_inputs == Abc_ObjFaninNum(pObj) );
- pObj->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pManFunc, pCell->pName );
+ pObj->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pManFunc, pCell->pName, NULL );
//printf( "Found gate %s\n", pCell->name );
}
}