Commit 9de8a0b3 by Alan Mishchenko

Improvements to Cba data-structure.

parent ea3133e3
...@@ -188,7 +188,7 @@ struct Cba_Man_t_ ...@@ -188,7 +188,7 @@ struct Cba_Man_t_
char * pName; // design name char * pName; // design name
char * pSpec; // spec file name char * pSpec; // spec file name
Abc_Nam_t * pStrs; // string manager Abc_Nam_t * pStrs; // string manager
Abc_Nam_t * pCons; // constant manager Abc_Nam_t * pFuns; // constant manager
Abc_Nam_t * pMods; // module name manager Abc_Nam_t * pMods; // module name manager
Vec_Int_t vNameMap; // mapping names Vec_Int_t vNameMap; // mapping names
Vec_Int_t vNameMap2;// mapping names Vec_Int_t vNameMap2;// mapping names
...@@ -222,9 +222,9 @@ static inline int Cba_ManStrId( Cba_Man_t * p, char * pStr ) { r ...@@ -222,9 +222,9 @@ static inline int Cba_ManStrId( Cba_Man_t * p, char * pStr ) { r
static inline int Cba_ManNewStrId( Cba_Man_t * p, char * pName ) { return Abc_NamStrFindOrAdd(p->pStrs, pName, NULL); } static inline int Cba_ManNewStrId( Cba_Man_t * p, char * pName ) { return Abc_NamStrFindOrAdd(p->pStrs, pName, NULL); }
static inline int Cba_ManNewStrId_( Cba_Man_t * p, char * pPref, int n, char * pSuff ) { char pStr[100]; sprintf(pStr, "%s%d%s", pPref?pPref:"", n, pSuff?pSuff:""); return Abc_NamStrFindOrAdd(p->pStrs, pStr, NULL); } static inline int Cba_ManNewStrId_( Cba_Man_t * p, char * pPref, int n, char * pSuff ) { char pStr[100]; sprintf(pStr, "%s%d%s", pPref?pPref:"", n, pSuff?pSuff:""); return Abc_NamStrFindOrAdd(p->pStrs, pStr, NULL); }
static inline int Cba_ManNameIdMax( Cba_Man_t * p ) { return Abc_NamObjNumMax(p->pStrs) + 1; } static inline int Cba_ManNameIdMax( Cba_Man_t * p ) { return Abc_NamObjNumMax(p->pStrs) + 1; }
static inline char * Cba_ManConst( Cba_Man_t * p, int i ) { return Abc_NamStr(p->pCons, i); } static inline char * Cba_ManConst( Cba_Man_t * p, int i ) { return Abc_NamStr(p->pFuns, i); }
static inline int Cba_ManConstId( Cba_Man_t * p, char * pStr ) { return Abc_NamStrFind(p->pCons, pStr); } static inline int Cba_ManConstId( Cba_Man_t * p, char * pStr ) { return Abc_NamStrFind(p->pFuns, pStr); }
static inline int Cba_ManConstIdMax( Cba_Man_t * p ) { return Abc_NamObjNumMax(p->pCons) + 1; } static inline int Cba_ManConstIdMax( Cba_Man_t * p ) { return Abc_NamObjNumMax(p->pFuns) + 1; }
static inline Cba_Man_t * Cba_NtkMan( Cba_Ntk_t * p ) { return p->pDesign; } static inline Cba_Man_t * Cba_NtkMan( Cba_Ntk_t * p ) { return p->pDesign; }
static inline Cba_Ntk_t * Cba_NtkNtk( Cba_Ntk_t * p, int i ) { return Cba_ManNtk(p->pDesign, i); } static inline Cba_Ntk_t * Cba_NtkNtk( Cba_Ntk_t * p, int i ) { return Cba_ManNtk(p->pDesign, i); }
...@@ -789,20 +789,20 @@ static inline void Cba_NtkPrint( Cba_Ntk_t * p ) ...@@ -789,20 +789,20 @@ static inline void Cba_NtkPrint( Cba_Ntk_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline Cba_Man_t * Cba_ManAlloc( char * pFileName, int nNtks, Abc_Nam_t * pStrs, Abc_Nam_t * pCons, Abc_Nam_t * pMods ) static inline Cba_Man_t * Cba_ManAlloc( char * pFileName, int nNtks, Abc_Nam_t * pStrs, Abc_Nam_t * pFuns, Abc_Nam_t * pMods )
{ {
Cba_Man_t * pNew = ABC_CALLOC( Cba_Man_t, 1 ); Cba_Man_t * pNew = ABC_CALLOC( Cba_Man_t, 1 );
pNew->pName = Extra_FileDesignName( pFileName ); pNew->pName = Extra_FileDesignName( pFileName );
pNew->pSpec = Abc_UtilStrsav( pFileName ); pNew->pSpec = Abc_UtilStrsav( pFileName );
pNew->pStrs = pStrs ? pStrs : Abc_NamStart( 1000, 24 ); pNew->pStrs = pStrs ? pStrs : Abc_NamStart( 1000, 24 );
pNew->pCons = pCons ? pCons : Abc_NamStart( 100, 24 ); pNew->pFuns = pFuns ? pFuns : Abc_NamStart( 100, 24 );
pNew->pMods = pMods ? pMods : Abc_NamStart( 100, 24 ); pNew->pMods = pMods ? pMods : Abc_NamStart( 100, 24 );
if ( pCons == NULL ) if ( pFuns == NULL )
{ {
Abc_NamStrFindOrAdd(pNew->pCons, "1\'b0", NULL); Abc_NamStrFindOrAdd(pNew->pFuns, "1\'b0", NULL);
Abc_NamStrFindOrAdd(pNew->pCons, "1\'b1", NULL); Abc_NamStrFindOrAdd(pNew->pFuns, "1\'b1", NULL);
Abc_NamStrFindOrAdd(pNew->pCons, "1\'bx", NULL); Abc_NamStrFindOrAdd(pNew->pFuns, "1\'bx", NULL);
Abc_NamStrFindOrAdd(pNew->pCons, "1\'bz", NULL); Abc_NamStrFindOrAdd(pNew->pFuns, "1\'bz", NULL);
} }
Vec_PtrGrow( &pNew->vNtks, nNtks+1 ); Vec_PtrPush( &pNew->vNtks, NULL ); Vec_PtrGrow( &pNew->vNtks, nNtks+1 ); Vec_PtrPush( &pNew->vNtks, NULL );
// set default root module // set default root module
...@@ -816,7 +816,7 @@ static inline void Cba_ManDupTypeNames( Cba_Man_t * pNew, Cba_Man_t * p ) ...@@ -816,7 +816,7 @@ static inline void Cba_ManDupTypeNames( Cba_Man_t * pNew, Cba_Man_t * p )
static inline Cba_Man_t * Cba_ManDup( Cba_Man_t * p, Vec_Int_t*(* pFuncOrder)(Cba_Ntk_t*) ) static inline Cba_Man_t * Cba_ManDup( Cba_Man_t * p, Vec_Int_t*(* pFuncOrder)(Cba_Ntk_t*) )
{ {
Cba_Ntk_t * pNtk, * pNtkNew; int i; Cba_Ntk_t * pNtk, * pNtkNew; int i;
Cba_Man_t * pNew = Cba_ManAlloc( p->pSpec, Cba_ManNtkNum(p), Abc_NamRef(p->pStrs), Abc_NamRef(p->pCons), Abc_NamStart(100, 24) ); Cba_Man_t * pNew = Cba_ManAlloc( p->pSpec, Cba_ManNtkNum(p), Abc_NamRef(p->pStrs), Abc_NamRef(p->pFuns), Abc_NamStart(100, 24) );
Cba_ManDupTypeNames( pNew, p ); Cba_ManDupTypeNames( pNew, p );
Cba_ManForEachNtk( p, pNtk, i ) Cba_ManForEachNtk( p, pNtk, i )
{ {
...@@ -843,7 +843,7 @@ static inline void Cba_ManFree( Cba_Man_t * p ) ...@@ -843,7 +843,7 @@ static inline void Cba_ManFree( Cba_Man_t * p )
Cba_NtkFree( pNtk ); Cba_NtkFree( pNtk );
ABC_FREE( p->vNtks.pArray ); ABC_FREE( p->vNtks.pArray );
Abc_NamDeref( p->pStrs ); Abc_NamDeref( p->pStrs );
Abc_NamDeref( p->pCons ); Abc_NamDeref( p->pFuns );
Abc_NamDeref( p->pMods ); Abc_NamDeref( p->pMods );
Vec_IntErase( &p->vNameMap ); Vec_IntErase( &p->vNameMap );
Vec_IntErase( &p->vUsed ); Vec_IntErase( &p->vUsed );
...@@ -909,7 +909,7 @@ static inline int Cba_ManNewConstId( Cba_Man_t * p, Vec_Str_t * vBits ) ...@@ -909,7 +909,7 @@ static inline int Cba_ManNewConstId( Cba_Man_t * p, Vec_Str_t * vBits )
Vec_StrForEachEntry( vBits, Symb, i ) Vec_StrForEachEntry( vBits, Symb, i )
Vec_StrPush( vOut, Symb ); Vec_StrPush( vOut, Symb );
Vec_StrPush( vOut, '\0' ); Vec_StrPush( vOut, '\0' );
return Abc_NamStrFindOrAdd(p->pCons, Vec_StrArray(vOut), NULL); return Abc_NamStrFindOrAdd(p->pFuns, Vec_StrArray(vOut), NULL);
} }
static inline int Cba_ManMemory( Cba_Man_t * p ) static inline int Cba_ManMemory( Cba_Man_t * p )
{ {
...@@ -918,7 +918,7 @@ static inline int Cba_ManMemory( Cba_Man_t * p ) ...@@ -918,7 +918,7 @@ static inline int Cba_ManMemory( Cba_Man_t * p )
nMem += p->pName ? (int)strlen(p->pName) : 0; nMem += p->pName ? (int)strlen(p->pName) : 0;
nMem += p->pSpec ? (int)strlen(p->pSpec) : 0; nMem += p->pSpec ? (int)strlen(p->pSpec) : 0;
nMem += Abc_NamMemUsed(p->pStrs); nMem += Abc_NamMemUsed(p->pStrs);
nMem += Abc_NamMemUsed(p->pCons); nMem += Abc_NamMemUsed(p->pFuns);
nMem += Abc_NamMemUsed(p->pMods); nMem += Abc_NamMemUsed(p->pMods);
nMem += (int)Vec_IntMemory(&p->vNameMap ); nMem += (int)Vec_IntMemory(&p->vNameMap );
nMem += (int)Vec_IntMemory(&p->vUsed ); nMem += (int)Vec_IntMemory(&p->vUsed );
...@@ -1017,8 +1017,10 @@ extern Cba_Man_t * Cba_ManExtractGroup( Cba_Man_t * p, Vec_Int_t * vObjs ); ...@@ -1017,8 +1017,10 @@ extern Cba_Man_t * Cba_ManExtractGroup( Cba_Man_t * p, Vec_Int_t * vObjs );
extern Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia ); extern Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia );
extern Cba_Man_t * Cba_ManInsertGroup( Cba_Man_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ); extern Cba_Man_t * Cba_ManInsertGroup( Cba_Man_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn );
/*=== cbaReadBlif.c ==========================================================*/ /*=== cbaReadBlif.c ==========================================================*/
extern void Prs_ManReadBlifTest( char * pFileName );
extern Cba_Man_t * Cba_ManReadBlif( char * pFileName ); extern Cba_Man_t * Cba_ManReadBlif( char * pFileName );
/*=== cbaReadVer.c ===========================================================*/ /*=== cbaReadVer.c ===========================================================*/
extern void Prs_ManReadVerilogTest( char * pFileName );
extern Cba_Man_t * Cba_ManReadVerilog( char * pFileName ); extern Cba_Man_t * Cba_ManReadVerilog( char * pFileName );
/*=== cbaWriteBlif.c =========================================================*/ /*=== cbaWriteBlif.c =========================================================*/
extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * p ); extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * p );
......
...@@ -101,17 +101,14 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -101,17 +101,14 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
FILE * pFile; FILE * pFile;
Cba_Man_t * p = NULL; Cba_Man_t * p = NULL;
char * pFileName = NULL; char * pFileName = NULL;
int c, fUseAbc = 0, fUsePtr = 0, fVerbose = 0; int c, fTest = 0, fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "apvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "tvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'a': case 't':
fUseAbc ^= 1; fTest ^= 1;
break;
case 'p':
fUsePtr ^= 1;
break; break;
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
...@@ -127,7 +124,7 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -127,7 +124,7 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
printf( "Cba_CommandRead(): Input file name should be given on the command line.\n" ); printf( "Cba_CommandRead(): Input file name should be given on the command line.\n" );
return 0; return 0;
} }
// get the file name // get the file name
pFileName = argv[globalUtilOptind]; pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "r" )) == NULL ) if ( (pFile = fopen( pFileName, "r" )) == NULL )
{ {
...@@ -138,24 +135,19 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -138,24 +135,19 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
} }
fclose( pFile ); fclose( pFile );
/* if ( fTest )
// perform reading
if ( fUseAbc || fUsePtr )
{ {
extern Vec_Ptr_t * Ptr_AbcDeriveDes( Abc_Ntk_t * pNtk ); if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) )
Abc_Ntk_t * pAbcNtk = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), 0 ); Prs_ManReadBlifTest( pFileName );
Vec_Ptr_t * vDes = Ptr_AbcDeriveDes( pAbcNtk ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) )
p = Cba_PtrTransformToCba( vDes ); Prs_ManReadVerilogTest( pFileName );
Cba_PtrFree( vDes ); // points to names in pAbcNtk else
if ( p )
{ {
ABC_FREE( p->pSpec ); printf( "Unrecognized input file extension.\n" );
p->pSpec = Abc_UtilStrsav( pAbcNtk->pSpec ); return 0;
} }
Abc_NtkDelete( pAbcNtk ); return 0;
} }
else
*/
if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) )
p = Cba_ManReadBlif( pFileName ); p = Cba_ManReadBlif( pFileName );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) )
...@@ -170,10 +162,9 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -170,10 +162,9 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
Cba_AbcUpdateMan( pAbc, p ); Cba_AbcUpdateMan( pAbc, p );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: @read [-apvh] <file_name>\n" ); Abc_Print( -2, "usage: @read [-tvh] <file_name>\n" );
Abc_Print( -2, "\t reads hierarchical design\n" ); Abc_Print( -2, "\t reads hierarchical design\n" );
// Abc_Print( -2, "\t-a : toggle using old ABC parser [default = %s]\n", fUseAbc? "yes": "no" ); Abc_Print( -2, "\t-t : toggle testing the parser [default = %s]\n", fTest? "yes": "no" );
// Abc_Print( -2, "\t-p : toggle using Ptr construction [default = %s]\n", fUsePtr? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n"); Abc_Print( -2, "\t-h : print the command usage\n");
return 1; return 1;
...@@ -194,7 +185,7 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -194,7 +185,7 @@ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Cba_Man_t * p = Cba_AbcGetMan(pAbc); Cba_Man_t * p = Cba_AbcGetMan(pAbc);
char * pFileName = NULL; char * pFileName = NULL;
int fInclineCats = 1; int fInclineCats = 0;
int c, fVerbose = 0; int c, fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
...@@ -602,8 +593,7 @@ usage: ...@@ -602,8 +593,7 @@ usage:
******************************************************************************/ ******************************************************************************/
int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
extern void Prs_ManReadVerilogTest(); Cba_Man_t * p = Cba_AbcGetMan(pAbc);
//Cba_Man_t * p = Cba_AbcGetMan(pAbc);
int c, fVerbose = 0; int c, fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
...@@ -619,14 +609,11 @@ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -619,14 +609,11 @@ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage; goto usage;
} }
} }
/*
if ( p == NULL ) if ( p == NULL )
{ {
Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" ); Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" );
return 0; return 0;
} }
*/
Prs_ManReadVerilogTest();
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: @test [-vh]\n" ); Abc_Print( -2, "usage: @test [-vh]\n" );
......
...@@ -422,7 +422,7 @@ void Cba_NtkCollapse_rec( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vSigs, in ...@@ -422,7 +422,7 @@ void Cba_NtkCollapse_rec( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vSigs, in
} }
Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p, int TypeBuf ) Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p, int TypeBuf )
{ {
Cba_Man_t * pNew = Cba_ManAlloc( p->pSpec, 1, Abc_NamRef(p->pStrs), Abc_NamRef(p->pCons), Abc_NamStart(100, 24) ); Cba_Man_t * pNew = Cba_ManAlloc( p->pSpec, 1, Abc_NamRef(p->pStrs), Abc_NamRef(p->pFuns), Abc_NamStart(100, 24) );
Cba_Ntk_t * pRoot = Cba_ManRoot( p ), * pRootNew; Cba_Ntk_t * pRoot = Cba_ManRoot( p ), * pRootNew;
Vec_Int_t * vSigs = Vec_IntAlloc( 1000 ); Vec_Int_t * vSigs = Vec_IntAlloc( 1000 );
int i, iObj, iObjNew, iFon, nObjs = 0, nFins = 0, nFons = 0; int i, iObj, iObjNew, iFon, nObjs = 0, nFins = 0, nFons = 0;
...@@ -593,7 +593,7 @@ void Cba_ManExtractGroupInt( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vObjs, ...@@ -593,7 +593,7 @@ void Cba_ManExtractGroupInt( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vObjs,
} }
Cba_Man_t * Cba_ManExtractGroup( Cba_Man_t * p, Vec_Int_t * vObjs ) Cba_Man_t * Cba_ManExtractGroup( Cba_Man_t * p, Vec_Int_t * vObjs )
{ {
Cba_Man_t * pNew = Cba_ManAlloc( p->pSpec, 1, Abc_NamRef(p->pStrs), Abc_NamRef(p->pCons), Abc_NamStart(100, 24) ); Cba_Man_t * pNew = Cba_ManAlloc( p->pSpec, 1, Abc_NamRef(p->pStrs), Abc_NamRef(p->pFuns), Abc_NamStart(100, 24) );
Cba_Ntk_t * pRoot = Cba_ManRoot( p ), * pRootNew; Cba_Ntk_t * pRoot = Cba_ManRoot( p ), * pRootNew;
Vec_Int_t * vFonIns = Cba_NtkCollectInFons( pRoot, vObjs ); Vec_Int_t * vFonIns = Cba_NtkCollectInFons( pRoot, vObjs );
Vec_Int_t * vFonOuts = Cba_NtkCollectOutFons( pRoot, vObjs ); Vec_Int_t * vFonOuts = Cba_NtkCollectOutFons( pRoot, vObjs );
......
...@@ -60,7 +60,7 @@ struct Prs_Ntk_t_ ...@@ -60,7 +60,7 @@ struct Prs_Ntk_t_
unsigned fHasCXs : 1; unsigned fHasCXs : 1;
unsigned fHasCZs : 1; unsigned fHasCZs : 1;
Abc_Nam_t * pStrs; Abc_Nam_t * pStrs;
Abc_Nam_t * pSops; Abc_Nam_t * pFuns;
// interface // interface
Vec_Int_t vOrder; // order of signals Vec_Int_t vOrder; // order of signals
// signal names // signal names
...@@ -90,7 +90,7 @@ struct Prs_Man_t_ ...@@ -90,7 +90,7 @@ struct Prs_Man_t_
char * pLimit; // end of file char * pLimit; // end of file
char * pCur; // current position char * pCur; // current position
Abc_Nam_t * pStrs; // string manager Abc_Nam_t * pStrs; // string manager
Abc_Nam_t * pSops; // cover manager Abc_Nam_t * pFuns; // cover manager
Prs_Ntk_t * pNtk; // current network Prs_Ntk_t * pNtk; // current network
Vec_Ptr_t * vNtks; // input networks Vec_Ptr_t * vNtks; // input networks
// temporary data // temporary data
...@@ -109,7 +109,7 @@ struct Prs_Man_t_ ...@@ -109,7 +109,7 @@ struct Prs_Man_t_
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_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 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; } static inline Abc_Nam_t * Prs_ManNameMan( Vec_Ptr_t * vPrs ) { return Prs_ManRoot(vPrs)->pStrs; }
static inline Abc_Nam_t * Prs_ManFuncMan( Vec_Ptr_t * vPrs ) { return Prs_ManRoot(vPrs)->pSops; } static inline Abc_Nam_t * Prs_ManFuncMan( Vec_Ptr_t * vPrs ) { return Prs_ManRoot(vPrs)->pFuns; }
static inline int Prs_NtkId( Prs_Ntk_t * p ) { return p->iModuleName; } static inline int Prs_NtkId( Prs_Ntk_t * p ) { return p->iModuleName; }
static inline int Prs_NtkPioNum( Prs_Ntk_t * p ) { return Vec_IntSize(&p->vInouts); } static inline int Prs_NtkPioNum( Prs_Ntk_t * p ) { return Vec_IntSize(&p->vInouts); }
...@@ -118,7 +118,8 @@ static inline int Prs_NtkPoNum( Prs_Ntk_t * p ) { return ...@@ -118,7 +118,8 @@ static inline int Prs_NtkPoNum( Prs_Ntk_t * p ) { return
static inline int Prs_NtkBoxNum( Prs_Ntk_t * p ) { return Vec_IntSize(&p->vObjs); } static inline int Prs_NtkBoxNum( Prs_Ntk_t * p ) { return Vec_IntSize(&p->vObjs); }
static inline int Prs_NtkObjNum( Prs_Ntk_t * p ) { return Prs_NtkPioNum(p) + Prs_NtkPiNum(p) + Prs_NtkPoNum(p) + Prs_NtkBoxNum(p); } static inline int Prs_NtkObjNum( Prs_Ntk_t * p ) { return Prs_NtkPioNum(p) + Prs_NtkPiNum(p) + Prs_NtkPoNum(p) + Prs_NtkBoxNum(p); }
static inline char * Prs_NtkStr( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pStrs, h); } static inline char * Prs_NtkStr( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pStrs, h); }
static inline char * Prs_NtkSop( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pSops, h); } static inline char * Prs_NtkSop( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pFuns, h); }
static inline char * Prs_NtkConst( Prs_Ntk_t * p, int h ) { return Abc_NamStr(p->pFuns, h); }
static inline char * Prs_NtkName( Prs_Ntk_t * p ) { return Prs_NtkStr(p, Prs_NtkId(p)); } static inline char * Prs_NtkName( Prs_Ntk_t * p ) { return Prs_NtkStr(p, Prs_NtkId(p)); }
static inline int Prs_NtkSigName( Prs_Ntk_t * p, int i ) { if (!p->fSlices) return i; assert(Abc_Lit2Att2(i) == CBA_PRS_NAME); return Abc_Lit2Var2(i); } static inline int Prs_NtkSigName( Prs_Ntk_t * p, int i ) { if (!p->fSlices) return i; assert(Abc_Lit2Att2(i) == CBA_PRS_NAME); return Abc_Lit2Var2(i); }
...@@ -186,7 +187,7 @@ static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices ) ...@@ -186,7 +187,7 @@ static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices )
p->pNtk->iModuleName = iName; p->pNtk->iModuleName = iName;
p->pNtk->fSlices = fSlices; p->pNtk->fSlices = fSlices;
p->pNtk->pStrs = Abc_NamRef( p->pStrs ); p->pNtk->pStrs = Abc_NamRef( p->pStrs );
p->pNtk->pSops = Abc_NamRef( p->pSops ); p->pNtk->pFuns = Abc_NamRef( p->pFuns );
Vec_PtrPush( p->vNtks, p->pNtk ); Vec_PtrPush( p->vNtks, p->pNtk );
} }
static inline void Prs_ManFinalizeNtk( Prs_Man_t * p ) static inline void Prs_ManFinalizeNtk( Prs_Man_t * p )
...@@ -229,6 +230,14 @@ static inline void Prs_NtkAddBox( Prs_Ntk_t * p, int ModName, int InstName, Vec_ ...@@ -229,6 +230,14 @@ static inline void Prs_NtkAddBox( Prs_Ntk_t * p, int ModName, int InstName, Vec_
Vec_IntAppend( &p->vBoxes, vTemp ); Vec_IntAppend( &p->vBoxes, vTemp );
} }
// parsing range
static inline void Prs_NtkParseRange( Prs_Ntk_t * p, int RangeId, int * pLeft, int * pRight )
{
char * pRange = Prs_NtkStr(p, RangeId);
char * pPivot = strchr( pRange, ':' );
*pLeft = atoi(pRange + 1);
*pRight = pPivot ? atoi(pPivot + 1) : *pLeft;
}
static inline char * Prs_ManLoadFile( char * pFileName, char ** ppLimit ) static inline char * Prs_ManLoadFile( char * pFileName, char ** ppLimit )
{ {
...@@ -269,17 +278,15 @@ static inline Prs_Man_t * Prs_ManAlloc( char * pFileName ) ...@@ -269,17 +278,15 @@ static inline Prs_Man_t * Prs_ManAlloc( char * pFileName )
p->pLimit = pLimit; p->pLimit = pLimit;
p->pCur = pBuffer; p->pCur = pBuffer;
p->pStrs = Abc_NamStart( 1000, 24 ); p->pStrs = Abc_NamStart( 1000, 24 );
p->pSops = Abc_NamStart( 100, 24 ); p->pFuns = Abc_NamStart( 100, 24 );
p->vNtks = Vec_PtrAlloc( 100 ); p->vNtks = Vec_PtrAlloc( 100 );
Abc_NamStrFindOrAdd( p->pSops, " 0\n", NULL );
Abc_NamStrFindOrAdd( p->pSops, " 1\n", NULL );
return p; return p;
} }
static inline void Prs_NtkFree( Prs_Ntk_t * p ) static inline void Prs_NtkFree( Prs_Ntk_t * p )
{ {
if ( p->pStrs ) Abc_NamDeref( p->pStrs ); if ( p->pStrs ) Abc_NamDeref( p->pStrs );
if ( p->pSops ) Abc_NamDeref( p->pSops ); if ( p->pFuns ) Abc_NamDeref( p->pFuns );
Vec_IntErase( &p->vOrder ); Vec_IntErase( &p->vOrder );
Vec_IntErase( &p->vInouts ); Vec_IntErase( &p->vInouts );
Vec_IntErase( &p->vInputs ); Vec_IntErase( &p->vInputs );
...@@ -307,7 +314,7 @@ static inline void Prs_ManVecFree( Vec_Ptr_t * vPrs ) ...@@ -307,7 +314,7 @@ static inline void Prs_ManVecFree( Vec_Ptr_t * vPrs )
static inline void Prs_ManFree( Prs_Man_t * p ) static inline void Prs_ManFree( Prs_Man_t * p )
{ {
if ( p->pStrs ) Abc_NamDeref( p->pStrs ); if ( p->pStrs ) Abc_NamDeref( p->pStrs );
if ( p->pSops ) Abc_NamDeref( p->pSops ); if ( p->pFuns ) Abc_NamDeref( p->pFuns );
if ( p->vNtks ) Prs_ManVecFree( p->vNtks ); if ( p->vNtks ) Prs_ManVecFree( p->vNtks );
// temporary // temporary
Vec_StrErase( &p->vCover ); Vec_StrErase( &p->vCover );
......
...@@ -235,7 +235,7 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p ) ...@@ -235,7 +235,7 @@ static inline void Prs_ManSaveCover( Prs_Man_t * p )
assert( Vec_StrSize(&p->vCover) > 0 ); assert( Vec_StrSize(&p->vCover) > 0 );
Vec_StrPush( &p->vCover, '\0' ); Vec_StrPush( &p->vCover, '\0' );
// iToken = Ptr_SopToType( Vec_StrArray(&p->vCover) ); // iToken = Ptr_SopToType( Vec_StrArray(&p->vCover) );
iToken = Abc_NamStrFindOrAdd( p->pSops, Vec_StrArray(&p->vCover), NULL ); iToken = Abc_NamStrFindOrAdd( p->pFuns, Vec_StrArray(&p->vCover), NULL );
Vec_StrClear( &p->vCover ); Vec_StrClear( &p->vCover );
// set the cover to the module of this box // set the cover to the module of this box
assert( Prs_BoxNtk(p->pNtk, Prs_NtkBoxNum(p->pNtk)-1) == 1 ); // default const 0 assert( Prs_BoxNtk(p->pNtk, Prs_NtkBoxNum(p->pNtk)-1) == 1 ); // default const 0
...@@ -409,6 +409,8 @@ Vec_Ptr_t * Prs_ManReadBlif( char * pFileName ) ...@@ -409,6 +409,8 @@ Vec_Ptr_t * Prs_ManReadBlif( char * pFileName )
Prs_Man_t * p = Prs_ManAlloc( pFileName ); Prs_Man_t * p = Prs_ManAlloc( pFileName );
if ( p == NULL ) if ( p == NULL )
return NULL; return NULL;
Abc_NamStrFindOrAdd( p->pFuns, " 0\n", NULL );
Abc_NamStrFindOrAdd( p->pFuns, " 1\n", NULL );
Prs_NtkAddBlifDirectives( p ); Prs_NtkAddBlifDirectives( p );
Prs_ManReadLines( p ); Prs_ManReadLines( p );
if ( Prs_ManErrorPrint(p) ) if ( Prs_ManErrorPrint(p) )
...@@ -428,20 +430,17 @@ Vec_Ptr_t * Prs_ManReadBlif( char * pFileName ) ...@@ -428,20 +430,17 @@ Vec_Ptr_t * Prs_ManReadBlif( char * pFileName )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Prs_ManReadBlifTest() void Prs_ManReadBlifTest( char * pFileName )
{ {
abctime clk = Abc_Clock(); abctime clk = Abc_Clock();
extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs ); Vec_Ptr_t * vPrs = Prs_ManReadBlif( pFileName );
// Vec_Ptr_t * vPrs = Prs_ManReadBlif( "aga/ray/ray_hie_oper.blif" );
// Vec_Ptr_t * vPrs = Prs_ManReadBlif( "c/hie/dump/1/netlist_1_out8.blif" );
Vec_Ptr_t * vPrs = Prs_ManReadBlif( "add2.blif" );
if ( !vPrs ) return; if ( !vPrs ) return;
printf( "Finished reading %d networks. ", Vec_PtrSize(vPrs) ); printf( "Finished reading %d networks. ", Vec_PtrSize(vPrs) );
printf( "NameIDs = %d. ", Abc_NamObjNumMax(Prs_ManNameMan(vPrs)) ); printf( "NameIDs = %d. ", Abc_NamObjNumMax(Prs_ManNameMan(vPrs)) );
printf( "Memory = %.2f MB. ", 1.0*Prs_ManMemory(vPrs)/(1<<20) ); printf( "Memory = %.2f MB. ", 1.0*Prs_ManMemory(vPrs)/(1<<20) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
// Abc_NamPrint( p->pStrs ); // Abc_NamPrint( p->pStrs );
Prs_ManWriteBlif( "add2_out.blif", vPrs ); Prs_ManWriteBlif( Extra_FileNameGenericAppend(pFileName, "_out.blif"), vPrs );
Prs_ManVecFree( vPrs ); Prs_ManVecFree( vPrs );
} }
...@@ -591,9 +590,9 @@ Cba_Man_t * Prs_ManBuildCbaBlif( char * pFileName, Vec_Ptr_t * vDes ) ...@@ -591,9 +590,9 @@ Cba_Man_t * Prs_ManBuildCbaBlif( char * pFileName, Vec_Ptr_t * vDes )
Prs_Ntk_t * pPrsRoot = Prs_ManRoot(vDes); Prs_Ntk_t * pPrsRoot = Prs_ManRoot(vDes);
// start the manager // start the manager
Abc_Nam_t * pStrs = Abc_NamRef(pPrsRoot->pStrs); Abc_Nam_t * pStrs = Abc_NamRef(pPrsRoot->pStrs);
Abc_Nam_t * pCons = Abc_NamRef(pPrsRoot->pSops); Abc_Nam_t * pFuns = Abc_NamRef(pPrsRoot->pFuns);
Abc_Nam_t * pMods = Abc_NamStart( 100, 24 ); Abc_Nam_t * pMods = Abc_NamStart( 100, 24 );
Cba_Man_t * p = Cba_ManAlloc( pFileName, Vec_PtrSize(vDes), pStrs, pCons, pMods ); Cba_Man_t * p = Cba_ManAlloc( pFileName, Vec_PtrSize(vDes), pStrs, pFuns, pMods );
// initialize networks // initialize networks
Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pPrsNtk, i ) Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pPrsNtk, i )
{ {
......
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