diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-02-09 23:27:40 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-02-09 23:27:40 -0800 |
commit | 089a8bbfc9861bb3dacc10710bd28e845b5c46f8 (patch) | |
tree | 6497b2c4625bbaac419cd7496cc46cea67cfd078 /src/base | |
parent | fd877c3f376fb50c5c5f863ad975867ad2eda994 (diff) | |
download | abc-089a8bbfc9861bb3dacc10710bd28e845b5c46f8.tar.gz abc-089a8bbfc9861bb3dacc10710bd28e845b5c46f8.tar.bz2 abc-089a8bbfc9861bb3dacc10710bd28e845b5c46f8.zip |
Several improvements to CBA data-structure.
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/cba/cba.h | 1 | ||||
-rw-r--r-- | src/base/cba/cbaBlast.c | 12 | ||||
-rw-r--r-- | src/base/cba/cbaNtk.c | 6 | ||||
-rw-r--r-- | src/base/cba/cbaPrs.h | 2 | ||||
-rw-r--r-- | src/base/cba/cbaPrsBuild.c | 136 | ||||
-rw-r--r-- | src/base/cba/cbaReadVer.c | 2 | ||||
-rw-r--r-- | src/base/cba/cbaWriteVer.c | 2 |
7 files changed, 126 insertions, 35 deletions
diff --git a/src/base/cba/cba.h b/src/base/cba/cba.h index 680ae09d..29e488c2 100644 --- a/src/base/cba/cba.h +++ b/src/base/cba/cba.h @@ -757,6 +757,7 @@ extern void Abc_FrameImportPtr( Vec_Ptr_t * vPtr ); extern Vec_Ptr_t * Abc_FrameExportPtr(); /*=== cbaBlast.c =============================================================*/ +extern int Cba_NtkBuildLibrary( Cba_Man_t * p ); extern Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose ); extern Cba_Man_t * Cba_ManInsertGia( Cba_Man_t * p, Gia_Man_t * pGia ); extern void * Cba_ManInsertAbc( Cba_Man_t * p, void * pAbc ); diff --git a/src/base/cba/cbaBlast.c b/src/base/cba/cbaBlast.c index eeb8e56d..f227ebf4 100644 --- a/src/base/cba/cbaBlast.c +++ b/src/base/cba/cbaBlast.c @@ -22,6 +22,7 @@ #include "base/abc/abc.h" #include "map/mio/mio.h" #include "bool/dec/dec.h" +#include "base/main/mainInt.h" ABC_NAMESPACE_IMPL_START @@ -489,6 +490,17 @@ void Cba_NtkPrepareLibrary( Cba_Man_t * p, Mio_Library_t * pLib ) Abc_NamStrFindOrAdd( p->pMods, Mio_GateReadName(pGate), NULL ); assert( Abc_NamObjNumMax(p->pMods) > 1 ); } +int Cba_NtkBuildLibrary( Cba_Man_t * p ) +{ + int RetValue = 1; + Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() ); + if ( pLib == NULL ) + printf( "The standard cell library is not available.\n" ), RetValue = 0; + else + Cba_NtkPrepareLibrary( p, pLib ); + p->pMioLib = pLib; + return RetValue; +} void Cba_NtkInsertNtk( Cba_Man_t * p, Abc_Ntk_t * pNtk ) { Cba_Ntk_t * pCbaNtk, * pRoot = Cba_ManRoot( p ); diff --git a/src/base/cba/cbaNtk.c b/src/base/cba/cbaNtk.c index 838f961f..13ed5c08 100644 --- a/src/base/cba/cbaNtk.c +++ b/src/base/cba/cbaNtk.c @@ -278,17 +278,15 @@ Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p ) Cba_ObjAlloc( pRootNew, CBA_OBJ_PO, Vec_IntEntry(vSigs, i) ); assert( Cba_NtkObjNum(pRootNew) == Cba_NtkObjNumAlloc(pRootNew) ); Vec_IntFree( vSigs ); -/* // transfer PI/PO names if ( Cba_NtkHasNames(pRoot) ) { Cba_NtkStartNames( pRootNew ); - Cba_NtkForEachPo( pRoot, iObj, i ) - Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) ); + Cba_NtkForEachPi( pRoot, iObj, i ) + Cba_ObjSetName( pRootNew, Cba_NtkPi(pRootNew, i), Cba_ObjName(pRoot, iObj) ); Cba_NtkForEachPo( pRoot, iObj, i ) Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) ); } -*/ return pNew; } diff --git a/src/base/cba/cbaPrs.h b/src/base/cba/cbaPrs.h index 5598ab2e..b82a3591 100644 --- a/src/base/cba/cbaPrs.h +++ b/src/base/cba/cbaPrs.h @@ -100,7 +100,7 @@ struct Prs_Man_t_ char ErrorStr[1000]; // error }; -static inline Prs_Ntk_t * Prs_ManNtk( Vec_Ptr_t * vPrs, int i ) { return (Prs_Ntk_t *)Vec_PtrEntry(vPrs, i); } +static inline Prs_Ntk_t * Prs_ManNtk( Vec_Ptr_t * vPrs, int i ) { return i >= 0 && i < Vec_PtrSize(vPrs) ? (Prs_Ntk_t *)Vec_PtrEntry(vPrs, i) : NULL; } static inline Prs_Ntk_t * Prs_ManRoot( Vec_Ptr_t * vPrs ) { return Prs_ManNtk(vPrs, 0); } static inline Abc_Nam_t * Prs_ManNameMan( Vec_Ptr_t * vPrs ) { return Prs_ManRoot(vPrs)->pStrs; } diff --git a/src/base/cba/cbaPrsBuild.c b/src/base/cba/cbaPrsBuild.c index 8dc89c0a..d3969c72 100644 --- a/src/base/cba/cbaPrsBuild.c +++ b/src/base/cba/cbaPrsBuild.c @@ -20,6 +20,8 @@ #include "cba.h" #include "cbaPrs.h" +#include "map/mio/mio.h" +#include "base/main/main.h" ABC_NAMESPACE_IMPL_START @@ -42,6 +44,33 @@ ABC_NAMESPACE_IMPL_START SeeAlso [] ***********************************************************************/ +int Prs_ManIsMapped( Prs_Ntk_t * pNtk ) +{ + Vec_Int_t * vSigs; int iBox; + Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() ); + if ( pLib == NULL ) + return 0; + Prs_NtkForEachBox( pNtk, vSigs, iBox ) + if ( !Prs_BoxIsNode(pNtk, iBox) ) + { + int NtkId = Prs_BoxNtk( pNtk, iBox ); + if ( Mio_LibraryReadGateByName(pLib, Prs_NtkStr(pNtk, NtkId), NULL) ) + return 1; + } + return 0; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ void Prs_ManVecFree( Vec_Ptr_t * vPrs ) { Prs_Ntk_t * pNtk; int i; @@ -109,6 +138,12 @@ void Prs_ManRemapOne( Vec_Int_t * vSigs, Prs_Ntk_t * pNtkBox, Vec_Int_t * vMap ) Prs_NtkForEachPo( pNtkBox, NameId, i ) Vec_IntWriteEntry( vMap, NameId, -1 ); } +void Prs_ManRemapGate( Vec_Int_t * vSigs ) +{ + int i, FormId; + Vec_IntForEachEntry( vSigs, FormId, i ) + Vec_IntWriteEntry( vSigs, i, i/2 + 1 ), i++; +} void Prs_ManRemapBoxes( Cba_Man_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_Int_t * vMap ) { Vec_Int_t * vSigs; int iBox; @@ -118,7 +153,10 @@ void Prs_ManRemapBoxes( Cba_Man_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Ve int NtkId = Prs_BoxNtk( pNtk, iBox ); int NtkIdNew = Cba_ManNtkFindId( pNew, Prs_NtkStr(pNtk, NtkId) ); Prs_BoxSetNtk( pNtk, iBox, NtkIdNew ); - Prs_ManRemapOne( vSigs, Prs_ManNtk(vDes, NtkIdNew), vMap ); + if ( NtkId < Cba_ManNtkNum(pNew) ) + Prs_ManRemapOne( vSigs, Prs_ManNtk(vDes, NtkIdNew), vMap ); + else + Prs_ManRemapGate( vSigs ); } } void Prs_ManCleanMap( Prs_Ntk_t * pNtk, Vec_Int_t * vMap ) @@ -157,24 +195,40 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_ if ( !Prs_BoxIsNode(pNtk, iBox) ) { pNtkBox = Prs_ManNtk( vDes, Prs_BoxNtk(pNtk, iBox) ); - iObj = Cba_BoxAlloc( pNew, CBA_OBJ_BOX, Prs_NtkPiNum(pNtkBox), Prs_NtkPoNum(pNtkBox), Prs_BoxNtk(pNtk, iBox) ); - Cba_ObjSetName( pNew, iObj, Prs_BoxName(pNtk, iBox) ); - Cba_NtkSetHost( Cba_ManNtk(pNew->pDesign, Prs_BoxNtk(pNtk, iBox)), Cba_NtkId(pNew), iObj ); - Vec_IntForEachEntry( vSigs, Index, i ) + if ( pNtkBox == NULL ) { - i++; - if ( --Index < Prs_NtkPiNum(pNtkBox) ) - continue; - assert( Index - Prs_NtkPiNum(pNtkBox) < Prs_NtkPoNum(pNtkBox) ); + iObj = Cba_BoxAlloc( pNew, CBA_BOX_GATE, Vec_IntSize(vSigs)/2-1, 1, Prs_BoxNtk(pNtk, iBox) + 1 ); // +1 to map NtkId into gate name + Cba_ObjSetName( pNew, iObj, Prs_BoxName(pNtk, iBox) ); // consider box output - NameId = Vec_IntEntry( vSigs, i ); + NameId = Vec_IntEntryLast( vSigs ); NameId = Prs_NtkSigName( pNtk, NameId ); if ( Vec_IntEntry(vMap, NameId) != -1 ) printf( "Box output name %d is already driven.\n", NameId ); - iTerm = Cba_BoxBo( pNew, iObj, Index - Prs_NtkPiNum(pNtkBox) ); + iTerm = Cba_BoxBo( pNew, iObj, 0 ); Cba_ObjSetName( pNew, iTerm, NameId ); Vec_IntWriteEntry( vMap, NameId, iTerm ); } + else + { + iObj = Cba_BoxAlloc( pNew, CBA_OBJ_BOX, Prs_NtkPiNum(pNtkBox), Prs_NtkPoNum(pNtkBox), Prs_BoxNtk(pNtk, iBox) ); + Cba_ObjSetName( pNew, iObj, Prs_BoxName(pNtk, iBox) ); + Cba_NtkSetHost( Cba_ManNtk(pNew->pDesign, Prs_BoxNtk(pNtk, iBox)), Cba_NtkId(pNew), iObj ); + Vec_IntForEachEntry( vSigs, Index, i ) + { + i++; + if ( --Index < Prs_NtkPiNum(pNtkBox) ) + continue; + assert( Index - Prs_NtkPiNum(pNtkBox) < Prs_NtkPoNum(pNtkBox) ); + // consider box output + NameId = Vec_IntEntry( vSigs, i ); + NameId = Prs_NtkSigName( pNtk, NameId ); + if ( Vec_IntEntry(vMap, NameId) != -1 ) + printf( "Box output name %d is already driven.\n", NameId ); + iTerm = Cba_BoxBo( pNew, iObj, Index - Prs_NtkPiNum(pNtkBox) ); + Cba_ObjSetName( pNew, iTerm, NameId ); + Vec_IntWriteEntry( vMap, NameId, iTerm ); + } + } // remember box Vec_IntPush( vBoxes, iObj ); } @@ -198,24 +252,47 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_ { pNtkBox = Prs_ManNtk( vDes, Prs_BoxNtk(pNtk, iBox) ); iObj = Vec_IntEntry( vBoxes, iBox ); - Vec_IntForEachEntry( vSigs, Index, i ) + if ( pNtkBox == NULL ) { - i++; - if ( --Index >= Prs_NtkPiNum(pNtkBox) ) - continue; - NameId = Vec_IntEntry( vSigs, i ); - NameId = Prs_NtkSigName( pNtk, NameId ); - iTerm = Cba_BoxBi( pNew, iObj, Index ); - if ( Vec_IntEntry(vMap, NameId) == -1 ) + Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 ) { - iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 ); - Vec_IntWriteEntry( vMap, NameId, iConst0+1 ); - if ( iNonDriven == -1 ) - iNonDriven = NameId; - nNonDriven++; + i++; + NameId = Vec_IntEntry( vSigs, i ); + NameId = Prs_NtkSigName( pNtk, NameId ); + iTerm = Cba_BoxBi( pNew, iObj, i/2 ); + if ( Vec_IntEntry(vMap, NameId) == -1 ) + { + iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 ); + Vec_IntWriteEntry( vMap, NameId, iConst0+1 ); + if ( iNonDriven == -1 ) + iNonDriven = NameId; + nNonDriven++; + } + Cba_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) ); + Cba_ObjSetName( pNew, iTerm, NameId ); + } + } + else + { + Vec_IntForEachEntry( vSigs, Index, i ) + { + i++; + if ( --Index >= Prs_NtkPiNum(pNtkBox) ) + continue; + NameId = Vec_IntEntry( vSigs, i ); + NameId = Prs_NtkSigName( pNtk, NameId ); + iTerm = Cba_BoxBi( pNew, iObj, Index ); + if ( Vec_IntEntry(vMap, NameId) == -1 ) + { + iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 ); + Vec_IntWriteEntry( vMap, NameId, iConst0+1 ); + if ( iNonDriven == -1 ) + iNonDriven = NameId; + nNonDriven++; + } + Cba_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) ); + Cba_ObjSetName( pNew, iTerm, NameId ); } - Cba_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) ); - Cba_ObjSetName( pNew, iTerm, NameId ); } } else @@ -279,8 +356,11 @@ Cba_Man_t * Prs_ManBuildCba( char * pFileName, Vec_Ptr_t * vDes ) pNew->pStrs = Abc_NamRef( pNtk->pStrs ); Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pNtk, i ) Cba_NtkAlloc( Cba_ManNtk(pNew, i), Prs_NtkId(pNtk), Prs_NtkPiNum(pNtk), Prs_NtkPoNum(pNtk), Prs_NtkCountObjects(pNtk) ); - Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pNtk, i ) - Prs_ManBuildNtk( Cba_ManNtk(pNew, i), vDes, pNtk, vMap, vTmp ); + if ( (pNtk->fMapped || (pNtk->fSlices && Prs_ManIsMapped(pNtk))) && !Cba_NtkBuildLibrary(pNew) ) + Cba_ManFree(pNew), pNew = NULL; + else + Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pNtk, i ) + Prs_ManBuildNtk( Cba_ManNtk(pNew, i), vDes, pNtk, vMap, vTmp ); assert( Vec_IntCountEntry(vMap, -1) == Vec_IntSize(vMap) ); Vec_IntFree( vMap ); Vec_IntFree( vTmp ); diff --git a/src/base/cba/cbaReadVer.c b/src/base/cba/cbaReadVer.c index 6d5a31df..0d9a1b8c 100644 --- a/src/base/cba/cbaReadVer.c +++ b/src/base/cba/cbaReadVer.c @@ -774,7 +774,7 @@ Vec_Ptr_t * Prs_ManReadVerilog( char * pFileName ) if ( p == NULL ) return NULL; Prs_NtkAddVerilogDirectives( p ); - Prs_ManReadDesign( p ); + Prs_ManReadDesign( p ); //Prs_ManPrintModules( p ); if ( Prs_ManErrorPrint(p) ) ABC_SWAP( Vec_Ptr_t *, vPrs, p->vNtks ); diff --git a/src/base/cba/cbaWriteVer.c b/src/base/cba/cbaWriteVer.c index 5b9fd6c2..efdd2171 100644 --- a/src/base/cba/cbaWriteVer.c +++ b/src/base/cba/cbaWriteVer.c @@ -330,7 +330,7 @@ void Cba_ManWriteVerilogNtk( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vMap, Vec_ for ( s = 0; s < 2; s++ ) { fprintf( pFile, " " ); - Cba_ManWriteVerilogSignalList( pFile, p, s, s==2, 1, vWires ); + Cba_ManWriteVerilogSignalList( pFile, p, s, s==1, 1, vWires ); fprintf( pFile, "\n" ); } fprintf( pFile, " );\n" ); |