From 40ea8a7598b89cfe0120fe32577c6cd9712938c5 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 10 Mar 2025 17:29:01 -0700 Subject: [PATCH] Enabling support for input/output names in mini mapping format. --- src/base/abci/abcMap.c | 70 ++++++++++++++++++++++++++--------------- src/base/abci/abcPart.c | 14 +++++---- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/base/abci/abcMap.c b/src/base/abci/abcMap.c index 663298afe..2c3021b45 100644 --- a/src/base/abci/abcMap.c +++ b/src/base/abci/abcMap.c @@ -852,7 +852,7 @@ Vec_Int_t * Abc_NtkWriteMiniMapping( Abc_Ntk_t * pNtk ) // write the numbers of CI/CO/Node/FF Vec_IntPush( vMapping, Abc_NtkCiNum(pNtk) ); Vec_IntPush( vMapping, Abc_NtkCoNum(pNtk) ); - Vec_IntPush( vMapping, Abc_NtkNodeNum(pNtk) ); + Vec_IntPush( vMapping, Vec_PtrSize(vNodes) ); Vec_IntPush( vMapping, Abc_NtkLatchNum(pNtk) ); // write the nodes vGates = Vec_StrAlloc( 10000 ); @@ -868,6 +868,15 @@ Vec_Int_t * Abc_NtkWriteMiniMapping( Abc_Ntk_t * pNtk ) // write the COs literals Abc_NtkForEachCo( pNtk, pObj, i ) Vec_IntPush( vMapping, Abc_ObjFanin0(pObj)->iTemp ); + // write signal names + Abc_NtkForEachCi( pNtk, pObj, i ) { + Vec_StrPrintStr( vGates, Abc_ObjName(pObj) ); + Vec_StrPush( vGates, '\0' ); + } + Abc_NtkForEachCo( pNtk, pObj, i ) { + Vec_StrPrintStr( vGates, Abc_ObjName(pObj) ); + Vec_StrPush( vGates, '\0' ); + } // finish off the array nExtra = 4 - Vec_StrSize(vGates) % 4; for ( i = 0; i < nExtra; i++ ) @@ -913,19 +922,23 @@ Abc_Ntk_t * Abc_NtkFromMiniMapping( int *pArray ) int i, k, nLeaves, Pos = 4; char * pBuffer, * pName; Mio_Gate_t *pGate; + Abc_Obj_t * pObj; nCis = pArray[0]; nCos = pArray[1]; nNodes = pArray[2]; nFlops = pArray[3]; - // create pi - for ( i = 0; i < nCis; i++ ) + // create pis + for ( i = 0; i < nCis-nFlops; i++ ) Abc_NtkCreatePi( pNtkMapped ); + // create pos + for ( i = 0; i < nCos-nFlops; i++ ) + Abc_NtkCreatePo( pNtkMapped ); + // create flops + for ( i = 0; i < nFlops; i++ ) + Abc_NtkAddLatch( pNtkMapped, NULL, ABC_INIT_ZERO ); // create nodes for ( i = 0; i < nNodes; i++ ) Abc_NtkCreateNode( pNtkMapped ); - // create po - for ( i = 0; i < nCos; i++ ) - Abc_NtkCreatePo( pNtkMapped ); // connect nodes for ( i = 0; i < nNodes; i++ ) { @@ -944,26 +957,21 @@ Abc_Ntk_t * Abc_NtkFromMiniMapping( int *pArray ) pGate = Mio_LibraryReadGateByName( pLib, pName, NULL ); Abc_NtkObj( pNtkMapped, nCis + i + 1 )->pData = pGate; } - Abc_NtkAddDummyPiNames( pNtkMapped ); - Abc_NtkAddDummyPoNames( pNtkMapped ); - // decouple the PO driver nodes to reduce the number of levels - int fFixDrivers = 1, fUseBuffs = 1, fVerbose = 1; - if ( fFixDrivers ) - { - int nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkMapped, !fUseBuffs ); - if ( fVerbose && nDupGates && !Abc_FrameReadFlag("silentmode") ) - { - if ( fUseBuffs ) - printf( "Added %d buffers/inverters to decouple the CO drivers.\n", nDupGates ); - else - printf( "Duplicated %d gates to decouple the CO drivers.\n", nDupGates ); - } + assert( Abc_NtkCiNum(pNtkMapped) == nCis ); + Abc_NtkForEachCi( pNtkMapped, pObj, i ) { + pName = pBuffer; + pBuffer += strlen(pName) + 1; + Abc_ObjAssignName( pObj, pName, NULL ); + } + assert( Abc_NtkCoNum(pNtkMapped) == nCos ); + Abc_NtkForEachCo( pNtkMapped, pObj, i ) { + pName = pBuffer; + pBuffer += strlen(pName) + 1; + Abc_ObjAssignName( pObj, pName, NULL ); } if ( !Abc_NtkCheck( pNtkMapped ) ) { - //extern void Abc_NtkPrintMiniMapping( int * pArray ); - //Abc_NtkPrintMiniMapping( pArray ); fprintf( stdout, "Abc_NtkFromMiniMapping(): Network check has failed.\n" ); } @@ -987,11 +995,11 @@ Abc_Ntk_t * Abc_NtkReadFromFile( char * pFileName ) if ( nSize == 0 ) return NULL; FILE * pFile = fopen( pFileName, "rb" ); - int * pArray = ABC_ALLOC( int, nSize ); + char * pArray = ABC_ALLOC( char, nSize ); int nSize2 = fread( pArray, sizeof(char), nSize, pFile ); assert( nSize2 == nSize ); fclose( pFile ); - Abc_Ntk_t * pNtk = Abc_NtkFromMiniMapping( pArray ); + Abc_Ntk_t * pNtk = Abc_NtkFromMiniMapping( (int*)pArray ); ABC_FREE( pArray ); return pNtk; } @@ -1032,8 +1040,8 @@ void Abc_NtkPrintMiniMapping( int * pArray ) printf( "The first %d object IDs (from 0 to %d) are reserved for the CIs.\n", nCis, nCis - 1 ); for ( i = 0; i < nNodes; i++ ) { - printf( "Node %d has fanins {", nCis + i ); nLeaves = pArray[Pos++]; + printf( "Node %d has %d fanins {", nCis + i, nLeaves ); for ( k = 0; k < nLeaves; k++ ) printf( " %d", pArray[Pos++] ); printf( " }\n" ); @@ -1047,6 +1055,18 @@ void Abc_NtkPrintMiniMapping( int * pArray ) pBuffer += strlen(pName) + 1; printf( "Node %d has gate \"%s\"\n", nCis + i, pName ); } + for ( i = 0; i < nCis; i++ ) + { + pName = pBuffer; + pBuffer += strlen(pName) + 1; + printf( "CI %d has name \"%s\"\n", i, pName ); + } + for ( i = 0; i < nCos; i++ ) + { + pName = pBuffer; + pBuffer += strlen(pName) + 1; + printf( "CO %d has name \"%s\"\n", i, pName ); + } } /**Function************************************************************* diff --git a/src/base/abci/abcPart.c b/src/base/abci/abcPart.c index 87d5ca81b..da4d55a65 100644 --- a/src/base/abci/abcPart.c +++ b/src/base/abci/abcPart.c @@ -1335,8 +1335,6 @@ int Abc_NtkStochProcess1( void * p ) Vec_Ptr_t * Abc_NtkStochProcess( Vec_Ptr_t * vWins, char * pScript, int nProcs, int TimeSecs, int fVerbose ) { if ( nProcs <= 2 ) { - if ( fVerbose ) - printf( "Running non-concurrent synthesis.\n" ), fflush(stdout); Abc_NtkStochSynthesis( vWins, pScript ); return NULL; } @@ -1352,8 +1350,6 @@ Vec_Ptr_t * Abc_NtkStochProcess( Vec_Ptr_t * vWins, char * pScript, int nProcs, pData[i].TimeOut = TimeSecs; Vec_PtrPush( vData, pData+i ); } - if ( fVerbose ) - printf( "Running concurrent synthesis with %d processes.\n", nProcs ), fflush(stdout); Util_ProcessThreads( Abc_NtkStochProcess1, vData, nProcs, TimeSecs, fVerbose ); // replace old AIGs by new AIGs Vec_PtrForEachEntry( Abc_Ntk_t *, vWins, pNtk, i ) { @@ -1850,8 +1846,14 @@ void Abc_NtkStochMap( int nSuppMax, int nIters, int TimeOut, int Seed, int fVerb Abc_Random(1); for ( i = 0; i < 10+Seed; i++ ) Abc_Random(0); - if ( fVerbose ) - printf( "Running %d iterations of script \"%s\".\n", nIters, pScript ); + if ( fVerbose ) { + printf( "Running %d iterations of the script \"%s\"", nIters, pScript ); + if ( nProcs > 2 ) + printf( " using %d concurrent threads.\n", nProcs-1 ); + else + printf( " without concurrency.\n" ); + fflush(stdout); + } Vec_Ptr_t * vIns = NULL, * vOuts = NULL, * vNodes = NULL; for ( i = 0; i < nIters; i++ ) {