Commit 356217ef by Alan Mishchenko

Improvements to Cba data-structure.

parent f039799b
......@@ -219,8 +219,6 @@ static inline Cba_Ntk_t * Cba_ManNtkFind( Cba_Man_t * p, char * pName ) { r
static inline Cba_Ntk_t * Cba_ManRoot( Cba_Man_t * p ) { return Cba_ManNtk(p, p->iRoot); }
static inline char * Cba_ManStr( Cba_Man_t * p, int i ) { return Abc_NamStr(p->pStrs, i); }
static inline int Cba_ManStrId( Cba_Man_t * p, char * pStr ) { return Abc_NamStrFind(p->pStrs, pStr); }
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_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->pFuns, i); }
static inline int Cba_ManConstId( Cba_Man_t * p, char * pStr ) { return Abc_NamStrFind(p->pFuns, pStr); }
......@@ -233,9 +231,9 @@ static inline int Cba_NtkPi( Cba_Ntk_t * p, int i ) { r
static inline int Cba_NtkPo( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vOutputs, i); }
static inline int Cba_NtkPioOrder( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vOrder, i); }
static inline int Cba_NtkBoxSeq( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vSeq, i); }
static inline Abc_Nam_t * Cba_NtkNam( Cba_Ntk_t * p ) { return p->pDesign->pStrs; }
static inline char * Cba_NtkStr( Cba_Ntk_t * p, int i ) { return Cba_ManStr(p->pDesign, i); }
static inline int Cba_NtkStrId( Cba_Ntk_t * p, char * pName ) { return Cba_ManStrId(p->pDesign, pName); }
static inline int Cba_NtkNewStrId( Cba_Ntk_t * p, char * pName ) { return Cba_ManNewStrId(p->pDesign, pName); }
static inline char * Cba_NtkConst( Cba_Ntk_t * p, int i ) { return Cba_ManConst(p->pDesign, i); }
static inline char * Cba_NtkSop( Cba_Ntk_t * p, int i ) { return Cba_ManConst(p->pDesign, i); }
static inline int Cba_NtkNameId( Cba_Ntk_t * p ) { return p->NameId; }
......@@ -351,7 +349,7 @@ static inline int Cba_ObjFinFon( Cba_Ntk_t * p, int i, int k ) { a
static inline int * Cba_ObjFinFons( Cba_Ntk_t * p, int i ) { assert(i>0); return Vec_IntEntryP(&p->vFinFon, Cba_ObjFin0(p, i)); }
static inline void Cba_ObjSetFinFon( Cba_Ntk_t * p, int i, int k, int x ) { assert(i>0); assert(Cba_ObjFinFon(p, i, k)== 0); Vec_IntWriteEntry(&p->vFinFon, Cba_ObjFin(p, i, k), x); }
static inline void Cba_ObjCleanFinFon( Cba_Ntk_t * p, int i, int k) { assert(i>0); assert(Cba_ObjFinFon(p, i, k) > 0); Vec_IntWriteEntry(&p->vFinFon, Cba_ObjFin(p, i, k), 0); }
static inline void Cba_ObjCleanFinFon( Cba_Ntk_t * p, int i, int k) { assert(i>0); assert(Cba_ObjFinFon(p, i, k)!= 0); Vec_IntWriteEntry(&p->vFinFon, Cba_ObjFin(p, i, k), 0); }
static inline void Cba_ObjPatchFinFon( Cba_Ntk_t * p, int i, int k, int x){ assert(i>0); Cba_ObjCleanFinFon(p, i, k); Cba_ObjSetFinFon(p, i, k, x); }
static inline int Cba_ObjNtkId( Cba_Ntk_t * p, int i ) { assert(i>0); return (Cba_ObjIsBoxUser(p, i) && Cba_NtkHasObjFuncs(p)) ? Cba_ObjFunc(p, i) : 0;}
......@@ -550,6 +548,23 @@ static inline void Cba_NtkFree( Cba_Ntk_t * p )
if ( p->vOther ) Vec_VecFree( (Vec_Vec_t *)p->vOther );
ABC_FREE( p );
}
static inline int Cba_NtkNewStrId( Cba_Ntk_t * pNtk, const char * format, ... )
{
Abc_Nam_t * p = Cba_NtkNam( pNtk );
Vec_Str_t * vBuf = Abc_NamBuffer( p );
int nAdded, nSize = 1000;
va_list args; va_start( args, format );
Vec_StrGrow( vBuf, Vec_StrSize(vBuf) + nSize );
nAdded = vsnprintf( Vec_StrLimit(vBuf), nSize, format, args );
if ( nAdded > nSize )
{
Vec_StrGrow( vBuf, Vec_StrSize(vBuf) + nAdded + nSize );
nSize = vsnprintf( Vec_StrLimit(vBuf), nAdded, format, args );
assert( nSize == nAdded );
}
va_end( args );
return Abc_NamStrFindOrAddLim( p, Vec_StrLimit(vBuf), Vec_StrLimit(vBuf) + nAdded, NULL );
}
static inline void Cba_NtkAdd( Cba_Man_t * p, Cba_Ntk_t * pNtk )
{
int fFound, NtkId = Abc_NamStrFindOrAdd( p->pMods, Cba_NtkName(pNtk), &fFound );
......@@ -589,7 +604,7 @@ static inline void Cba_NtkCreateFonNames( Cba_Ntk_t * p, char * pPref )
Cba_FonSetName( p, iFon, Cba_ObjName(p, iObj) );
Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
if ( NameId == 0 )
Vec_IntWriteEntry( &p->vFonName, iFon, Cba_ManNewStrId_(p->pDesign, pPref, iFon, NULL) );
Vec_IntWriteEntry( &p->vFonName, iFon, Cba_NtkNewStrId(p, "%s%d", pPref, iFon) );
}
static inline void Cba_NtkMissingFonNames( Cba_Ntk_t * p, char * pPref )
{
......@@ -602,7 +617,7 @@ static inline void Cba_NtkMissingFonNames( Cba_Ntk_t * p, char * pPref )
Cba_FonSetName( p, iFon, Cba_ObjName(p, iObj) );
Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
if ( NameId == 0 )
Cba_FonSetName( p, iFon, Cba_ManNewStrId_(p->pDesign, pPref, iFon, NULL) );
Cba_FonSetName( p, iFon, Cba_NtkNewStrId(p, "%s%d", pPref, iFon) );
}
static inline int Cba_NtkIsSeq( Cba_Ntk_t * p )
{
......@@ -865,6 +880,10 @@ static inline void Cba_ManSetMap( Cba_Man_t * p, int i, int x )
Vec_IntSetEntry( &p->vNameMap, i, x );
Vec_IntPush( &p->vUsed, i );
}
static inline void Cba_ManUnsetMap( Cba_Man_t * p, int i )
{
Vec_IntSetEntry( &p->vNameMap, i, 0 );
}
static inline void Cba_ManCleanMap( Cba_Man_t * p )
{
int i, Entry;
......@@ -874,6 +893,7 @@ static inline void Cba_ManCleanMap( Cba_Man_t * p )
}
static inline int Cba_NtkGetMap( Cba_Ntk_t * p, int i ) { return Cba_ManGetMap(p->pDesign, i); }
static inline void Cba_NtkSetMap( Cba_Ntk_t * p, int i, int x ) { Cba_ManSetMap(p->pDesign, i, x); }
static inline void Cba_NtkUnsetMap( Cba_Ntk_t * p, int i ) { Cba_ManUnsetMap(p->pDesign, i); }
static inline void Cba_NtkCleanMap( Cba_Ntk_t * p ) { Cba_ManCleanMap(p->pDesign); }
static inline int Cba_ManGetMap2( Cba_Man_t * p, int i )
......@@ -886,6 +906,10 @@ static inline void Cba_ManSetMap2( Cba_Man_t * p, int i, int x )
Vec_IntSetEntry( &p->vNameMap2, i, x );
Vec_IntPush( &p->vUsed2, i );
}
static inline void Cba_ManUnsetMap2( Cba_Man_t * p, int i )
{
Vec_IntSetEntry( &p->vNameMap2, i, 0 );
}
static inline void Cba_ManCleanMap2( Cba_Man_t * p )
{
int i, Entry;
......@@ -895,6 +919,7 @@ static inline void Cba_ManCleanMap2( Cba_Man_t * p )
}
static inline int Cba_NtkGetMap2( Cba_Ntk_t * p, int i ) { return Cba_ManGetMap2(p->pDesign, i); }
static inline void Cba_NtkSetMap2( Cba_Ntk_t * p, int i, int x ) { Cba_ManSetMap2(p->pDesign, i, x); }
static inline void Cba_NtkUnsetMap2( Cba_Ntk_t * p, int i ) { Cba_ManUnsetMap2(p->pDesign, i); }
static inline void Cba_NtkCleanMap2( Cba_Ntk_t * p ) { Cba_ManCleanMap2(p->pDesign); }
static inline int Cba_ManNewConstId( Cba_Man_t * p, Vec_Str_t * vBits )
......@@ -1005,6 +1030,8 @@ extern Cba_Man_t * Cba_ManReadCba( char * pFileName );
extern void Cba_ManWriteCba( char * pFileName, Cba_Man_t * p );
/*=== cbaCom.c ===============================================================*/
/*=== cbaNtk.c ===============================================================*/
extern void Cba_ManPrintDistrib( Cba_Man_t * p );
extern void Cba_NtkPrintDistrib( Cba_Ntk_t * p );
//extern void Cba_ManPrepareTypeNames( Cba_Man_t * p );
extern void Cba_NtkObjOrder( Cba_Ntk_t * p, Vec_Int_t * vObjs, Vec_Int_t * vNameIds );
extern int Cba_NtkCiFonNum( Cba_Ntk_t * p );
......@@ -1026,6 +1053,7 @@ extern Cba_Man_t * Cba_ManReadVerilog( char * pFileName );
extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * p );
extern void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p );
/*=== cbaWriteVer.c ==========================================================*/
extern void Cba_ManCreatePrimMap( char ** pMap );
extern void Prs_ManWriteVerilog( char * pFileName, Vec_Ptr_t * p );
extern void Cba_ManWriteVerilog( char * pFileName, Cba_Man_t * p, int fInlineConcat );
......
......@@ -32,6 +32,73 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cba_NtkCollectDistrib( Cba_Ntk_t * p, int * pCounts, int * pUserCounts )
{
int i;
Cba_NtkForEachBox( p, i )
if ( Cba_ObjIsBoxUser(p, i) )
pUserCounts[Cba_ObjNtkId(p, i)]++;
else
pCounts[Cba_ObjType(p, i)]++;
}
void Cba_NtkPrintDistribStat( Cba_Ntk_t * p, int * pCounts, int * pUserCounts )
{
Cba_Ntk_t * pNtk; int i;
printf( "Primitives (%d):\n", Cba_NtkBoxPrimNum(p) );
for ( i = 0; i < CBA_BOX_LAST; i++ )
if ( pCounts[i] )
printf( "%-20s = %5d\n", Cba_NtkTypeName(p, i), pCounts[i] );
printf( "User hierarchy (%d):\n", Cba_NtkBoxUserNum(p) );
Cba_ManForEachNtk( p->pDesign, pNtk, i )
if ( pUserCounts[i] )
printf( "%-20s = %5d\n", Cba_NtkName(pNtk), pUserCounts[i] );
}
void Cba_NtkPrintDistrib( Cba_Ntk_t * p )
{
int pCounts[CBA_BOX_LAST] = {0};
int * pUserCounts = ABC_CALLOC( int, Cba_ManNtkNum(p->pDesign) + 1 );
Cba_ManCreatePrimMap( p->pDesign->pTypeNames );
Cba_NtkCollectDistrib( p, pCounts, pUserCounts );
Cba_NtkPrintDistribStat( p, pCounts, pUserCounts );
ABC_FREE( pUserCounts );
}
void Cba_ManPrintDistribStat( Cba_Man_t * p, int * pCounts, int * pUserCounts )
{
Cba_Ntk_t * pNtk = Cba_ManRoot(p); int i;
printf( "Primitives:\n" );
for ( i = 0; i < CBA_BOX_LAST; i++ )
if ( pCounts[i] )
printf( "%-20s = %5d\n", Cba_NtkTypeName(pNtk, i), pCounts[i] );
printf( "User hierarchy:\n" );
Cba_ManForEachNtk( p, pNtk, i )
if ( pUserCounts[i] )
printf( "%-20s = %5d\n", Cba_NtkName(pNtk), pUserCounts[i] );
}
void Cba_ManPrintDistrib( Cba_Man_t * p )
{
Cba_Ntk_t * pNtk; int i;
int pCounts[CBA_BOX_LAST] = {0};
int * pUserCounts = ABC_CALLOC( int, Cba_ManNtkNum(p) + 1 );
Cba_ManCreatePrimMap( p->pTypeNames );
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkCollectDistrib( pNtk, pCounts, pUserCounts );
Cba_ManPrintDistribStat( p, pCounts, pUserCounts );
ABC_FREE( pUserCounts );
}
/**Function*************************************************************
Synopsis [Order objects by box type and then by name.]
Description []
......@@ -686,7 +753,7 @@ Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia )
Cba_NtkCleanObjNames( pNtk );
Gia_ManForEachCiId( pGia, iObj, i )
{
NameId = pGia->vNamesIn? Abc_NamStrFindOrAdd(p->pStrs, Vec_PtrEntry(pGia->vNamesIn, i), NULL) : Cba_ManNewStrId_(p, "i", i, NULL);
NameId = pGia->vNamesIn? Abc_NamStrFindOrAdd(p->pStrs, Vec_PtrEntry(pGia->vNamesIn, i), NULL) : Cba_NtkNewStrId(pNtk, "i%d", i);
iObjNew = Cba_ObjAlloc( pNtk, CBA_OBJ_PI, 0, 1 );
Cba_ObjSetName( pNtk, iObjNew, NameId );
Vec_IntWriteEntry( vLit2Fon, Abc_Var2Lit(iObj, 0), Cba_ObjFon0(pNtk, iObjNew) );
......@@ -708,7 +775,7 @@ Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia )
iObjNew = Cba_ObjAlloc( pNtk, CBA_BOX_BUF, 1, 1 );
Cba_ObjSetFinFon( pNtk, iObjNew, 0, iFon0 );
iFon0 = Cba_ObjFon0(pNtk, iObjNew); // non-const fon unique for this output
NameId = pGia->vNamesOut? Abc_NamStrFindOrAdd(p->pStrs, Vec_PtrEntry(pGia->vNamesOut, i), NULL) : Cba_ManNewStrId_(p, "o", i, NULL);
NameId = pGia->vNamesOut? Abc_NamStrFindOrAdd(p->pStrs, Vec_PtrEntry(pGia->vNamesOut, i), NULL) : Cba_NtkNewStrId(pNtk, "o%d", i);
iObjNew = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, 1, 0 );
Cba_ObjSetName( pNtk, iObjNew, NameId );
Cba_ObjSetFinFon( pNtk, iObjNew, 0, iFon0 );
......
......@@ -193,14 +193,19 @@ void Prs_ManWriteVerilog( char * pFileName, Vec_Ptr_t * vPrs )
void Cba_ManCreatePrimMap( char ** pMap )
{
memset( pMap, 0, sizeof(char *) * CBA_BOX_LAST );
pMap[ CBA_BOX_SLICE ] = "sli";
pMap[ CBA_BOX_CATIN ] = "icc";
pMap[ CBA_BOX_CATOUT ] = "occ";
pMap[ CBA_BOX_BUF ] = "";
pMap[ CBA_BOX_INV ] = "~";
pMap[ CBA_BOX_AND ] = "&";
pMap[ CBA_BOX_NAND ] = "~&";
pMap[ CBA_BOX_NAND ] = "&";
pMap[ CBA_BOX_OR ] = "|";
pMap[ CBA_BOX_NOR ] = "~|";
pMap[ CBA_BOX_NOR ] = "|";
pMap[ CBA_BOX_XOR ] = "^";
pMap[ CBA_BOX_XNOR ] = "~^";
pMap[ CBA_BOX_XNOR ] = "^";
pMap[ CBA_BOX_SHARP ] = "&";
pMap[ CBA_BOX_SHARPL ] = "&";
pMap[ CBA_BOX_MUX ] = "?";
......@@ -218,12 +223,12 @@ void Cba_ManCreatePrimMap( char ** pMap )
pMap[ CBA_BOX_LNOR ] = NULL;
pMap[ CBA_BOX_LXOR ] = "^^";
pMap[ CBA_BOX_LXNOR ] = NULL;
pMap[ CBA_BOX_NMUX ] = NULL;
pMap[ CBA_BOX_SEL ] = NULL;
pMap[ CBA_BOX_NMUX ] = "nmux";
pMap[ CBA_BOX_SEL ] = "sel";
pMap[ CBA_BOX_PSEL ] = NULL;
pMap[ CBA_BOX_ENC ] = NULL;
pMap[ CBA_BOX_PENC ] = NULL;
pMap[ CBA_BOX_DEC ] = NULL;
pMap[ CBA_BOX_DEC ] = "dec";
pMap[ CBA_BOX_EDEC ] = NULL;
pMap[ CBA_BOX_ADD ] = "+";
pMap[ CBA_BOX_SUB ] = "-";
......@@ -242,39 +247,23 @@ void Cba_ManCreatePrimMap( char ** pMap )
pMap[ CBA_BOX_NEQU ] = "!=";
pMap[ CBA_BOX_SHIL ] = "<<";
pMap[ CBA_BOX_SHIR ] = ">>";
pMap[ CBA_BOX_ROTL ] = NULL;
pMap[ CBA_BOX_ROTR ] = NULL;
pMap[ CBA_BOX_ROTL ] = "rotL";
pMap[ CBA_BOX_ROTR ] = "rotR";
pMap[ CBA_BOX_TRI ] = "tri";
pMap[ CBA_BOX_RAM ] = "ram";
pMap[ CBA_BOX_RAMR ] = "ramR";
pMap[ CBA_BOX_RAMW ] = "ramW";
pMap[ CBA_BOX_RAMWC ] = "ramWC";
pMap[ CBA_BOX_RAMBOX ] = "ramBox";
pMap[ CBA_BOX_LATCH ] = "lat";
pMap[ CBA_BOX_LATCHRS] = "latrs";
pMap[ CBA_BOX_DFF ] = "dff";
pMap[ CBA_BOX_DFFRS ] = "dffrs";
}
#ifdef WIN32
#define vsnprintf _vsnprintf
#endif
#include <stdio.h>
//extern int vsnprintf(char * s, size_t n, const char * format, va_list arg);
static inline void Vec_StrPrintF( Vec_Str_t * p, const char * format, ... )
{
va_list args;
char * pBuffer;
int nBuffer, nSize = 1000;
va_start( args, format );
Vec_StrGrow( p, Vec_StrSize(p) + nSize );
pBuffer = Vec_StrArray(p) + Vec_StrSize(p);
nBuffer = vsnprintf( pBuffer, nSize, format, args );
if ( nBuffer > nSize )
{
Vec_StrGrow( p, Vec_StrSize(p) + nBuffer + nSize );
pBuffer = Vec_StrArray(p) + Vec_StrSize(p);
nSize = vsnprintf( pBuffer, nBuffer, format, args );
assert( nSize == nBuffer );
}
p->nSize += nBuffer;
va_end( args );
}
static inline int Cba_NameIsLegalInVerilog( char * pName )
{
......@@ -303,19 +292,24 @@ static inline char * Cba_NameLegal( char * pName )
}
char * Cba_ObjGetName( Cba_Ntk_t * p, int i )
{
int fLegalize = 1;
char * pName = Cba_ObjNameStr(p, i); assert( pName );
return fLegalize ? Cba_NameLegal(pName) : pName;
char * pName = Cba_ObjNameStr(p, i);
if ( pName == NULL )
return pName;
if ( Cba_NameIsLegalInVerilog(pName) )
return pName;
return Vec_StrPrintF( Abc_NamBuffer(Cba_NtkNam(p)), "\\%s ", pName );
}
char * Cba_FonGetName( Cba_Ntk_t * p, int i )
{
int fLegalize = 1;
char * pName = Cba_FonNameStr(p, i); assert( pName );
return fLegalize ? Cba_NameLegal(pName) : pName;
char * pName = Cba_FonNameStr(p, i);
if ( pName == NULL )
return pName;
if ( Cba_NameIsLegalInVerilog(pName) )
return pName;
return Vec_StrPrintF( Abc_NamBuffer(Cba_NtkNam(p)), "\\%s ", pName );
}
void Cba_ManWriteFonRange( Cba_Ntk_t * p, int iFon )
{
Vec_Str_t * vStr = &p->pDesign->vOut;
......@@ -421,11 +415,7 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
Vec_StrPrintStr( vStr, Cba_ObjIsPi(p, iObj) ? "input " : "output " );
Cba_ManWriteFonRange( p, Cba_ObjIsPi(p, iObj) ? Cba_ObjFon0(p, iObj) : Cba_ObjFinFon(p, iObj, 0) );
Vec_StrPrintStr( vStr, Cba_ObjGetName(p, iObj) );
// Vec_StrPush( vStr, ';' );
// for ( k = Vec_StrSize(vStr); k < Offset + 40; k++ )
// Vec_StrPush( vStr, ' ' );
Vec_StrPrintF( vStr, ";%*s", Offset + 40 - Vec_StrSize(vStr), "" );
Cba_ManWriteLineFile( p, iObj, FileAttr, LineAttr );
Vec_StrPush( vStr, '\n' );
}
......@@ -433,6 +423,8 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
// write objects
Cba_NtkForEachBox( p, iObj )
{
// char * pNameNtk = Cba_NtkName(p);
// char * pNameInst = Cba_ObjGetName(p, iObj);
int Type = Cba_ObjType(p, iObj);
if ( Cba_ObjIsSlice(p, iObj) )
continue;
......@@ -813,12 +805,17 @@ void Cba_ManWriteVerilogNtk( Cba_Ntk_t * p, int fInlineConcat )
}
else if ( Cba_NtkTypeName(p, Type) ) // binary operation
{
int fCompl = (Type == CBA_BOX_NAND || Type == CBA_BOX_NOR || Type == CBA_BOX_XNOR);
Vec_StrPush( vStr, ' ' );
if ( fCompl )
Vec_StrPrintStr( vStr, "!(" );
Cba_ManWriteFonName( p, Cba_ObjFinFon(p, iObj, 0), fInlineConcat, 0 );
Vec_StrPush( vStr, ' ' );
Vec_StrPrintStr( vStr, Cba_NtkTypeName(p, Type) );
Vec_StrPush( vStr, ' ' );
Cba_ManWriteFonName( p, Cba_ObjFinFon(p, iObj, 1), fInlineConcat, 0 );
if ( fCompl )
Vec_StrPrintStr( vStr, ")" );
}
else // unknown
{
......
......@@ -81,6 +81,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
////////////////////////////////////////////////////////////////////////
/// NAMESPACES ///
......
......@@ -62,7 +62,9 @@ extern int Abc_NamStrFind( Abc_Nam_t * p, char * pStr );
extern int Abc_NamStrFindLim( Abc_Nam_t * p, char * pStr, char * pLim );
extern int Abc_NamStrFindOrAdd( Abc_Nam_t * p, char * pStr, int * pfFound );
extern int Abc_NamStrFindOrAddLim( Abc_Nam_t * p, char * pStr, char * pLim, int * pfFound );
extern int Abc_NamStrFindOrAddF( Abc_Nam_t * p, const char * format, ... );
extern char * Abc_NamStr( Abc_Nam_t * p, int id );
extern Vec_Str_t * Abc_NamBuffer( Abc_Nam_t * p );
extern Vec_Int_t * Abc_NamComputeIdMap( Abc_Nam_t * p1, Abc_Nam_t * p2 );
extern int Abc_NamReportCommon( Vec_Int_t * vNameIds1, Abc_Nam_t * p1, Abc_Nam_t * p2 );
extern char * Abc_NamReportUnique( Vec_Int_t * vNameIds1, Abc_Nam_t * p1, Abc_Nam_t * p2 );
......
......@@ -283,6 +283,10 @@ static inline char * Vec_StrArray( Vec_Str_t * p )
{
return p->pArray;
}
static inline char * Vec_StrLimit( Vec_Str_t * p )
{
return p->pArray + p->nSize;
}
/**Function*************************************************************
......@@ -299,6 +303,10 @@ static inline int Vec_StrSize( Vec_Str_t * p )
{
return p->nSize;
}
static inline void Vec_StrSetSize( Vec_Str_t * p, int nSize )
{
p->nSize = nSize;
}
/**Function*************************************************************
......@@ -668,6 +676,39 @@ static inline void Vec_StrPrintStr( Vec_Str_t * p, const char * pStr )
Vec_StrPush( p, pStr[i] );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
#ifdef WIN32
#define vsnprintf _vsnprintf
#endif
static inline char * Vec_StrPrintF( Vec_Str_t * p, const char * format, ... )
{
int nAdded, nSize = 1000;
va_list args; va_start( args, format );
Vec_StrGrow( p, Vec_StrSize(p) + nSize );
nAdded = vsnprintf( Vec_StrLimit(p), nSize, format, args );
if ( nAdded > nSize )
{
Vec_StrGrow( p, Vec_StrSize(p) + nAdded + nSize );
nSize = vsnprintf( Vec_StrLimit(p), nAdded, format, args );
assert( nSize == nAdded );
}
p->nSize += nAdded;
va_end( args );
return Vec_StrLimit(p) - nAdded;
}
/**Function*************************************************************
Synopsis [Appends the string to the char vector.]
......
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