Commit 26b8116a by Alan Mishchenko

Changing memory model of Cba_Ntk_t.

parent 63ce84d8
...@@ -29,10 +29,9 @@ ...@@ -29,10 +29,9 @@
#include "aig/gia/gia.h" #include "aig/gia/gia.h"
#include "misc/extra/extra.h" #include "misc/extra/extra.h"
#include "misc/util/utilNam.h" #include "misc/util/utilNam.h"
#include "misc/mem/mem.h"
#include "misc/extra/extra.h" #include "misc/extra/extra.h"
#include "misc/util/utilTruth.h" #include "misc/util/utilTruth.h"
#include "misc/vec/vecWec.h" #include "misc/vec/vecSet.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// PARAMETERS /// /// PARAMETERS ///
...@@ -89,7 +88,7 @@ struct Cba_Man_t_ ...@@ -89,7 +88,7 @@ struct Cba_Man_t_
Abc_Nam_t * pFuncs; // functionality manager Abc_Nam_t * pFuncs; // functionality manager
Cba_Man_t * pLib; // library Cba_Man_t * pLib; // library
// internal data // internal data
Mem_Flex_t * pMem; // memory Vec_Set_t Mem; // memory
Vec_Ptr_t vNtks; // networks Vec_Ptr_t vNtks; // networks
int iRoot; // root network int iRoot; // root network
}; };
...@@ -109,7 +108,7 @@ struct Cba_Ntk_t_ ...@@ -109,7 +108,7 @@ struct Cba_Ntk_t_
Vec_Int_t vTypes; // types (used by parser to store Cba_PrsType_t) Vec_Int_t vTypes; // types (used by parser to store Cba_PrsType_t)
Vec_Int_t vFuncs; // functions (used by parser to store function) Vec_Int_t vFuncs; // functions (used by parser to store function)
Vec_Int_t vInstIds; // instance names (used by parser to store instance name as NameId) Vec_Int_t vInstIds; // instance names (used by parser to store instance name as NameId)
Vec_Wec_t vFanins; // fanins (used by parser to store fanin/fanout/range as NameId) Vec_Int_t vFanins; // fanins (used by parser to store fanin/fanout/range as NameId)
// attributes // attributes
Vec_Int_t vNameIds; // original names as NameId Vec_Int_t vNameIds; // original names as NameId
Vec_Int_t vRanges; // ranges as NameId Vec_Int_t vRanges; // ranges as NameId
...@@ -121,17 +120,28 @@ static inline char * Cba_ManName( Cba_Man_t * p ) { re ...@@ -121,17 +120,28 @@ static inline char * Cba_ManName( Cba_Man_t * p ) { re
static inline int Cba_ManNtkNum( Cba_Man_t * p ) { return Vec_PtrSize(&p->vNtks) - 1; } static inline int Cba_ManNtkNum( Cba_Man_t * p ) { return Vec_PtrSize(&p->vNtks) - 1; }
static inline Cba_Ntk_t * Cba_ManNtk( Cba_Man_t * p, int i ) { assert( i > 0 ); return (Cba_Ntk_t *)Vec_PtrEntry(&p->vNtks, i); } static inline Cba_Ntk_t * Cba_ManNtk( Cba_Man_t * p, int i ) { assert( i > 0 ); return (Cba_Ntk_t *)Vec_PtrEntry(&p->vNtks, i); }
static inline Cba_Ntk_t * Cba_ManRoot( Cba_Man_t * p ) { return Cba_ManNtk(p, p->iRoot); } static inline Cba_Ntk_t * Cba_ManRoot( Cba_Man_t * p ) { return Cba_ManNtk(p, p->iRoot); }
static inline Vec_Set_t * Cba_ManMem( Cba_Man_t * p ) { return &p->Mem; }
static inline int Cba_ManMemSave( Cba_Man_t * p, int * d, int s ) { return Vec_SetAppend(Cba_ManMem(p), d, s); }
static inline int * Cba_ManMemRead( Cba_Man_t * p, int h ) { return (int *)Vec_SetEntry(Cba_ManMem(p), h); }
static inline char * Cba_NtkName( Cba_Ntk_t * p ) { return p->pName; } static inline char * Cba_NtkName( Cba_Ntk_t * p ) { return p->pName; }
static inline int Cba_NtkObjNum( Cba_Ntk_t * p ) { return Vec_WecSize(&p->vFanins); } static inline Cba_Man_t * Cba_NtkMan( Cba_Ntk_t * p ) { return p->pDesign; }
static inline int Cba_NtkObjNum( Cba_Ntk_t * p ) { return Vec_IntSize(&p->vFanins); }
static inline char * Cba_NtkStr( Cba_Ntk_t * p, int i ) { return Abc_NamStr(p->pDesign->pNames, i); } static inline char * Cba_NtkStr( Cba_Ntk_t * p, int i ) { return Abc_NamStr(p->pDesign->pNames, i); }
static inline char * Cba_NtkModelStr( Cba_Ntk_t * p, int i ) { return Abc_NamStr(p->pDesign->pModels, i); } static inline char * Cba_NtkModelStr( Cba_Ntk_t * p, int i ) { return Abc_NamStr(p->pDesign->pModels, i); }
static inline char * Cba_NtkFuncStr( Cba_Ntk_t * p, int i ) { return Abc_NamStr(p->pDesign->pFuncs, i); } static inline char * Cba_NtkFuncStr( Cba_Ntk_t * p, int i ) { return Abc_NamStr(p->pDesign->pFuncs, i); }
static inline Vec_Set_t * Cba_NtkMem( Cba_Ntk_t * p ) { return Cba_ManMem(p->pDesign); }
static inline int Cba_NtkMemSave( Cba_Ntk_t * p, int * d, int s ) { return Cba_ManMemSave(p->pDesign, d, s); }
static inline int * Cba_NtkMemRead( Cba_Ntk_t * p, int h ) { return Cba_ManMemRead(p->pDesign, h); }
static inline Cba_ObjType_t Cba_ObjType( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vTypes, i); } static inline Cba_ObjType_t Cba_ObjType( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vTypes, i); }
static inline int Cba_ObjFuncId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vFuncs, i); } static inline int Cba_ObjFuncId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vFuncs, i); }
static inline int Cba_ObjInstId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vInstIds, i); } static inline int Cba_ObjInstId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vInstIds, i); }
static inline Vec_Int_t * Cba_ObjFanins( Cba_Ntk_t * p, int i ) { return Vec_WecEntry(&p->vFanins, i); } static inline int * Cba_ObjFaninArray( Cba_Ntk_t * p, int i ) { return Cba_NtkMemRead(p, Vec_IntEntry(&p->vFanins, i)); }
static inline int Cba_ObjFaninNum( Cba_Ntk_t * p, int i ) { return *Cba_ObjFaninArray(p, i); }
static inline int * Cba_ObjFanins( Cba_Ntk_t * p, int i ) { return Cba_ObjFaninArray(p, i) + 1; }
static inline Vec_Int_t * Cba_ObjFaninVec( Cba_Ntk_t * p, int i ) { static Vec_Int_t V; V.pArray = Cba_ObjFaninArray(p, i); V.nSize = V.nCap = *V.pArray++; return &V; }
static inline Vec_Int_t * Cba_ObjFaninVec2( Cba_Ntk_t * p, int i ) { static Vec_Int_t W; W.pArray = Cba_ObjFaninArray(p, i); W.nSize = W.nCap = *W.pArray++; return &W; }
static inline int Cba_ObjNameId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vNameIds, i); } static inline int Cba_ObjNameId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vNameIds, i); }
static inline int Cba_ObjRangeId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vRanges, i); } static inline int Cba_ObjRangeId( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vRanges, i); }
...@@ -158,7 +168,7 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { re ...@@ -158,7 +168,7 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { re
#define Cba_NtkForEachObjType( p, Type, i ) \ #define Cba_NtkForEachObjType( p, Type, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1); i++ ) for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1); i++ )
#define Cba_NtkForEachObjTypeFuncFanins( p, Type, Func, vFanins, i ) \ #define Cba_NtkForEachObjTypeFuncFanins( p, Type, Func, vFanins, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1) && (((Func) = Cba_ObjFuncId(p, i)), 1) && (((vFanins) = Cba_ObjFanins(p, i)), 1); i++ ) for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1) && (((Func) = Cba_ObjFuncId(p, i)), 1) && (((vFanins) = Cba_ObjFaninVec(p, i)), 1); i++ )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -167,34 +177,13 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { re ...@@ -167,34 +177,13 @@ static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { re
static inline Cba_Ntk_t * Cba_NtkAlloc( Cba_Man_t * p, char * pName ) static inline Cba_Ntk_t * Cba_NtkAlloc( Cba_Man_t * p, char * pName )
{ {
Cba_Ntk_t * pNtk = ABC_CALLOC( Cba_Ntk_t, 1 ); Cba_Ntk_t * pNtk = Vec_SetFetch( Cba_ManMem(p), sizeof(Cba_Ntk_t) );
memset( pNtk, 0, sizeof(Cba_Ntk_t) );
pNtk->pDesign = p; pNtk->pDesign = p;
pNtk->pName = Abc_UtilStrsav(pName); pNtk->pName = Vec_SetStrsav( Cba_ManMem(p), pName );
Vec_PtrPush( &p->vNtks, pNtk ); Vec_PtrPush( &p->vNtks, pNtk );
return pNtk; return pNtk;
} }
static inline void Cba_NtkFree( Cba_Ntk_t * p )
{
// Vec_IntErase( &p->vInouts );
// Vec_IntErase( &p->vInputs );
// Vec_IntErase( &p->vOutputs );
// Vec_IntErase( &p->vWires );
// Vec_IntErase( &p->vTypes );
// Vec_IntErase( &p->vFuncs );
// Vec_IntErase( &p->vInstIds );
ABC_FREE( p->vFanins.pArray );
Vec_IntErase( &p->vNameIds );
Vec_IntErase( &p->vRanges );
Vec_IntErase( &p->vCopies );
ABC_FREE( p->pName );
ABC_FREE( p );
}
static inline int Cba_NtkMemory( Cba_Ntk_t * p )
{
return Vec_WecMemory(&p->vFanins);
}
static inline Cba_Man_t * Cba_ManAlloc( char * pFileName ) static inline Cba_Man_t * Cba_ManAlloc( char * pFileName )
{ {
...@@ -207,17 +196,14 @@ static inline Cba_Man_t * Cba_ManAlloc( char * pFileName ) ...@@ -207,17 +196,14 @@ static inline Cba_Man_t * Cba_ManAlloc( char * pFileName )
p->pModels = Abc_NamStart( 1000, 20 ); p->pModels = Abc_NamStart( 1000, 20 );
p->pFuncs = Abc_NamStart( 1000, 20 ); p->pFuncs = Abc_NamStart( 1000, 20 );
// internal data // internal data
p->pMem = Mem_FlexStart(); Vec_SetAlloc_( &p->Mem, 20 );
Vec_PtrPush( &p->vNtks, NULL ); Vec_PtrPush( &p->vNtks, NULL );
return p; return p;
} }
static inline void Cba_ManFree( Cba_Man_t * p ) static inline void Cba_ManFree( Cba_Man_t * p )
{ {
Cba_Ntk_t * pNtk; int i;
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkFree( pNtk );
ABC_FREE( p->vNtks.pArray ); ABC_FREE( p->vNtks.pArray );
Mem_FlexStop( p->pMem, 0 ); Vec_SetFree_( &p->Mem );
// design names // design names
Abc_NamStop( p->pNames ); Abc_NamStop( p->pNames );
Abc_NamStop( p->pModels ); Abc_NamStop( p->pModels );
...@@ -228,15 +214,12 @@ static inline void Cba_ManFree( Cba_Man_t * p ) ...@@ -228,15 +214,12 @@ static inline void Cba_ManFree( Cba_Man_t * p )
} }
static inline int Cba_ManMemory( Cba_Man_t * p ) static inline int Cba_ManMemory( Cba_Man_t * p )
{ {
Cba_Ntk_t * pNtk; int i;
int nMem = sizeof(Cba_Man_t); int nMem = sizeof(Cba_Man_t);
nMem += Abc_NamMemUsed(p->pNames); nMem += Abc_NamMemUsed(p->pNames);
nMem += Abc_NamMemUsed(p->pModels); nMem += Abc_NamMemUsed(p->pModels);
nMem += Abc_NamMemUsed(p->pFuncs); nMem += Abc_NamMemUsed(p->pFuncs);
nMem += Mem_FlexReadMemUsage(p->pMem); nMem += Vec_SetMemoryAll(&p->Mem);
nMem += (int)Vec_PtrMemory(&p->vNtks); nMem += (int)Vec_PtrMemory(&p->vNtks);
Cba_ManForEachNtk( p, pNtk, i )
nMem += Cba_NtkMemory( pNtk );
return nMem; return nMem;
} }
......
...@@ -33,9 +33,9 @@ static int Cba_CommandPs ( Abc_Frame_t * pAbc, int argc, char ** argv ); ...@@ -33,9 +33,9 @@ static int Cba_CommandPs ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandBlast ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Cba_CommandBlast ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Cba_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Cba_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
static inline Cba_Ntk_t * Cba_AbcGetNtk( Abc_Frame_t * pAbc ) { return (Cba_Ntk_t *)pAbc->pAbcCba; } static inline Cba_Ntk_t * Cba_AbcGetNtk( Abc_Frame_t * pAbc ) { return (Cba_Ntk_t *)pAbc->pAbcCba; }
static inline void Cba_AbcFreeNtk( Abc_Frame_t * pAbc ) { if ( pAbc->pAbcCba ) Cba_NtkFree(Cba_AbcGetNtk(pAbc)); } static inline void Cba_AbcFreeNtk( Abc_Frame_t * pAbc ) { if ( pAbc->pAbcCba ) Cba_ManFree(Cba_NtkMan(Cba_AbcGetNtk(pAbc))); }
static inline void Cba_AbcUpdateNtk( Abc_Frame_t * pAbc, Cba_Ntk_t * pNtk ) { Cba_AbcFreeNtk(pAbc); pAbc->pAbcCba = pNtk; } static inline void Cba_AbcUpdateNtk( Abc_Frame_t * pAbc, Cba_Ntk_t * pNtk ) { Cba_AbcFreeNtk(pAbc); pAbc->pAbcCba = pNtk; }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
......
...@@ -68,7 +68,7 @@ struct Cba_Prs_t_ ...@@ -68,7 +68,7 @@ struct Cba_Prs_t_
Vec_Int_t vTypesCur; // Cba_PrsType_t Vec_Int_t vTypesCur; // Cba_PrsType_t
Vec_Int_t vFuncsCur; // functions (node->func; box->module; gate->cell; latch->init; concat->unused) Vec_Int_t vFuncsCur; // functions (node->func; box->module; gate->cell; latch->init; concat->unused)
Vec_Int_t vInstIdsCur; // instance names Vec_Int_t vInstIdsCur; // instance names
Vec_Wec_t vFaninsCur; // instances Vec_Int_t vFaninsCur; // instances
// temporary data // temporary data
Vec_Str_t vCover; // one SOP cover Vec_Str_t vCover; // one SOP cover
Vec_Int_t vTemp; // array of tokens Vec_Int_t vTemp; // array of tokens
...@@ -113,12 +113,21 @@ static inline int Cba_PrsErrorPrint( Cba_Prs_t * p ) ...@@ -113,12 +113,21 @@ static inline int Cba_PrsErrorPrint( Cba_Prs_t * p )
// copy contents to the vector // copy contents to the vector
static inline int Cba_PrsSetupDataInt( Cba_Prs_t * p, Vec_Int_t * vFrom )
{
int h = Vec_SetFetchH( Cba_ManMem(p->pDesign), sizeof(int) * (Vec_IntSize(vFrom) + 1) );
int * pArray = (int *)Vec_SetEntry( Cba_ManMem(p->pDesign), h );
pArray[0] = Vec_IntSize(vFrom);
memcpy( pArray+1, Vec_IntArray(vFrom), sizeof(int) * Vec_IntSize(vFrom) );
Vec_IntClear( vFrom );
return h;
}
static inline void Cba_PrsSetupVecInt( Cba_Prs_t * p, Vec_Int_t * vTo, Vec_Int_t * vFrom ) static inline void Cba_PrsSetupVecInt( Cba_Prs_t * p, Vec_Int_t * vTo, Vec_Int_t * vFrom )
{ {
if ( Vec_IntSize(vFrom) == 0 ) if ( Vec_IntSize(vFrom) == 0 )
return; return;
vTo->nSize = vTo->nCap = Vec_IntSize(vFrom); vTo->nSize = vTo->nCap = Vec_IntSize(vFrom);
vTo->pArray = (int *)Mem_FlexEntryFetch( p->pDesign->pMem, sizeof(int) * Vec_IntSize(vFrom) ); vTo->pArray = (int *)Vec_SetFetch( Cba_ManMem(p->pDesign), sizeof(int) * Vec_IntSize(vFrom) );
memcpy( Vec_IntArray(vTo), Vec_IntArray(vFrom), sizeof(int) * Vec_IntSize(vFrom) ); memcpy( Vec_IntArray(vTo), Vec_IntArray(vFrom), sizeof(int) * Vec_IntSize(vFrom) );
Vec_IntClear( vFrom ); Vec_IntClear( vFrom );
} }
...@@ -133,8 +142,7 @@ static inline Cba_Ntk_t * Cba_PrsAddCurrentModel( Cba_Prs_t * p, int iNameId ) ...@@ -133,8 +142,7 @@ static inline Cba_Ntk_t * Cba_PrsAddCurrentModel( Cba_Prs_t * p, int iNameId )
Cba_PrsSetupVecInt( p, &pNtk->vTypes, &p->vTypesCur ); Cba_PrsSetupVecInt( p, &pNtk->vTypes, &p->vTypesCur );
Cba_PrsSetupVecInt( p, &pNtk->vFuncs, &p->vFuncsCur ); Cba_PrsSetupVecInt( p, &pNtk->vFuncs, &p->vFuncsCur );
Cba_PrsSetupVecInt( p, &pNtk->vInstIds, &p->vInstIdsCur ); Cba_PrsSetupVecInt( p, &pNtk->vInstIds, &p->vInstIdsCur );
pNtk->vFanins = p->vFaninsCur; Cba_PrsSetupVecInt( p, &pNtk->vFanins, &p->vFaninsCur );
Vec_WecZero( &p->vFaninsCur );
return pNtk; return pNtk;
} }
...@@ -192,7 +200,7 @@ static inline void Cba_PrsFree( Cba_Prs_t * p ) ...@@ -192,7 +200,7 @@ static inline void Cba_PrsFree( Cba_Prs_t * p )
Vec_IntErase( &p->vTypesCur ); Vec_IntErase( &p->vTypesCur );
Vec_IntErase( &p->vFuncsCur ); Vec_IntErase( &p->vFuncsCur );
Vec_IntErase( &p->vInstIdsCur ); Vec_IntErase( &p->vInstIdsCur );
ABC_FREE( p->vFaninsCur.pArray ); Vec_IntErase( &p->vFaninsCur );
// temporary // temporary
Vec_StrErase( &p->vCover ); Vec_StrErase( &p->vCover );
Vec_IntErase( &p->vTemp ); Vec_IntErase( &p->vTemp );
......
...@@ -267,7 +267,7 @@ static inline int Cba_PrsReadNode( Cba_Prs_t * p ) ...@@ -267,7 +267,7 @@ static inline int Cba_PrsReadNode( Cba_Prs_t * p )
// save results // save results
Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE ); Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE );
Vec_IntPush( &p->vFuncsCur, 1 ); // default const 0 function Vec_IntPush( &p->vFuncsCur, 1 ); // default const 0 function
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 0; return 0;
} }
static inline int Cba_PrsReadBox( Cba_Prs_t * p, int fGate ) static inline int Cba_PrsReadBox( Cba_Prs_t * p, int fGate )
...@@ -278,7 +278,7 @@ static inline int Cba_PrsReadBox( Cba_Prs_t * p, int fGate ) ...@@ -278,7 +278,7 @@ static inline int Cba_PrsReadBox( Cba_Prs_t * p, int fGate )
// save results // save results
Vec_IntPush( &p->vTypesCur, CBA_PRS_BOX ); Vec_IntPush( &p->vTypesCur, CBA_PRS_BOX );
Vec_IntPush( &p->vFuncsCur, iToken ); Vec_IntPush( &p->vFuncsCur, iToken );
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 0; return 0;
} }
static inline int Cba_PrsReadLatch( Cba_Prs_t * p ) static inline int Cba_PrsReadLatch( Cba_Prs_t * p )
...@@ -301,7 +301,7 @@ static inline int Cba_PrsReadLatch( Cba_Prs_t * p ) ...@@ -301,7 +301,7 @@ static inline int Cba_PrsReadLatch( Cba_Prs_t * p )
// save results // save results
Vec_IntPush( &p->vTypesCur, CBA_PRS_LATCH ); Vec_IntPush( &p->vTypesCur, CBA_PRS_LATCH );
Vec_IntPush( &p->vFuncsCur, iToken ); Vec_IntPush( &p->vFuncsCur, iToken );
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 0; return 0;
} }
static inline int Cba_PrsReadShort( Cba_Prs_t * p ) static inline int Cba_PrsReadShort( Cba_Prs_t * p )
...@@ -318,7 +318,7 @@ static inline int Cba_PrsReadShort( Cba_Prs_t * p ) ...@@ -318,7 +318,7 @@ static inline int Cba_PrsReadShort( Cba_Prs_t * p )
// save results // save results
Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE ); Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE );
Vec_IntPush( &p->vFuncsCur, 2 ); // default buffer function Vec_IntPush( &p->vFuncsCur, 2 ); // default buffer function
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 0; return 0;
} }
static inline int Cba_PrsReadModel( Cba_Prs_t * p ) static inline int Cba_PrsReadModel( Cba_Prs_t * p )
......
...@@ -370,10 +370,8 @@ static inline int Cba_PrsReadConcat( Cba_Prs_t * p, Vec_Int_t * vTemp2 ) ...@@ -370,10 +370,8 @@ static inline int Cba_PrsReadConcat( Cba_Prs_t * p, Vec_Int_t * vTemp2 )
Vec_IntPush( &p->vTypesCur, CBA_PRS_CONCAT ); Vec_IntPush( &p->vTypesCur, CBA_PRS_CONCAT );
Vec_IntPush( &p->vFuncsCur, 0 ); Vec_IntPush( &p->vFuncsCur, 0 );
Vec_IntPush( &p->vInstIdsCur, 0 ); Vec_IntPush( &p->vInstIdsCur, 0 );
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), vTemp2 ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, vTemp2) );
// return the result return Vec_IntSize(&p->vFaninsCur);
assert( Vec_WecSize(&p->vFaninsCur) > 0 );
return Vec_WecSize(&p->vFaninsCur);
} }
static inline int Cba_PrsReadSignalOrConcat( Cba_Prs_t * p, int * pName, int * pRange ) static inline int Cba_PrsReadSignalOrConcat( Cba_Prs_t * p, int * pName, int * pRange )
{ {
...@@ -502,7 +500,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p ) ...@@ -502,7 +500,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p )
Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE ); Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE );
Vec_IntPush( &p->vFuncsCur, fCompl ? CBA_NODE_INV : CBA_NODE_BUF ); Vec_IntPush( &p->vFuncsCur, fCompl ? CBA_NODE_INV : CBA_NODE_BUF );
Vec_IntPush( &p->vInstIdsCur, 0 ); Vec_IntPush( &p->vInstIdsCur, 0 );
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 1; return 1;
} }
if ( Cba_PrsIsChar(p, '&') ) if ( Cba_PrsIsChar(p, '&') )
...@@ -537,7 +535,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p ) ...@@ -537,7 +535,7 @@ static inline int Cba_PrsReadAssign( Cba_Prs_t * p )
Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE ); Vec_IntPush( &p->vTypesCur, CBA_PRS_NODE );
Vec_IntPush( &p->vFuncsCur, Oper ); Vec_IntPush( &p->vFuncsCur, Oper );
Vec_IntPush( &p->vInstIdsCur, 0 ); Vec_IntPush( &p->vInstIdsCur, 0 );
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 1; return 1;
} }
static inline int Cba_PrsReadInstance( Cba_Prs_t * p, int Func ) static inline int Cba_PrsReadInstance( Cba_Prs_t * p, int Func )
...@@ -567,7 +565,7 @@ static inline int Cba_PrsReadInstance( Cba_Prs_t * p, int Func ) ...@@ -567,7 +565,7 @@ static inline int Cba_PrsReadInstance( Cba_Prs_t * p, int Func )
Vec_IntPush( &p->vTypesCur, Type ); Vec_IntPush( &p->vTypesCur, Type );
Vec_IntPush( &p->vFuncsCur, Func ); Vec_IntPush( &p->vFuncsCur, Func );
Vec_IntPush( &p->vInstIdsCur, InstId ); Vec_IntPush( &p->vInstIdsCur, InstId );
Cba_PrsSetupVecInt( p, Vec_WecPushLevel(&p->vFaninsCur), &p->vTemp ); Vec_IntPush( &p->vFaninsCur, Cba_PrsSetupDataInt(p, &p->vTemp) );
return 1; return 1;
} }
...@@ -635,8 +633,7 @@ static inline int Cba_PrsReadModule( Cba_Prs_t * p ) ...@@ -635,8 +633,7 @@ static inline int Cba_PrsReadModule( Cba_Prs_t * p )
Vec_IntPush( &p->vFailed, p->iModuleName ); Vec_IntPush( &p->vFailed, p->iModuleName );
// cleanup // cleanup
Vec_IntClear( &p->vWiresCur ); Vec_IntClear( &p->vWiresCur );
ABC_FREE( p->vFaninsCur.pArray ); Vec_IntClear( &p->vFaninsCur );
Vec_WecZero( &p->vFaninsCur );
Vec_IntClear( &p->vTypesCur ); Vec_IntClear( &p->vTypesCur );
Vec_IntClear( &p->vFuncsCur ); Vec_IntClear( &p->vFuncsCur );
Vec_IntClear( &p->vInstIdsCur ); Vec_IntClear( &p->vInstIdsCur );
......
...@@ -95,7 +95,7 @@ void Cba_PrsWriteVerilogConcat( FILE * pFile, Cba_Ntk_t * p, int Id ) ...@@ -95,7 +95,7 @@ void Cba_PrsWriteVerilogConcat( FILE * pFile, Cba_Ntk_t * p, int Id )
{ {
extern void Cba_PrsWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins ); extern void Cba_PrsWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins );
fprintf( pFile, "{" ); fprintf( pFile, "{" );
Cba_PrsWriteVerilogArray2( pFile, p, Cba_ObjFanins(p, Id) ); Cba_PrsWriteVerilogArray2( pFile, p, Cba_ObjFaninVec2(p, Id) );
fprintf( pFile, "}" ); fprintf( pFile, "}" );
} }
void Cba_PrsWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins ) void Cba_PrsWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins )
...@@ -140,11 +140,11 @@ void Cba_PrsWriteVerilogNodes( FILE * pFile, Cba_Ntk_t * p ) ...@@ -140,11 +140,11 @@ void Cba_PrsWriteVerilogNodes( FILE * pFile, Cba_Ntk_t * p )
if ( Func >= CBA_NODE_BUF && Func <= CBA_NODE_XNOR ) if ( Func >= CBA_NODE_BUF && Func <= CBA_NODE_XNOR )
{ {
fprintf( pFile, " %s (", s_NodeTypes[Func] ); fprintf( pFile, " %s (", s_NodeTypes[Func] );
Cba_PrsWriteVerilogArray2( pFile, p, Cba_ObjFanins(p, i) ); Cba_PrsWriteVerilogArray2( pFile, p, Cba_ObjFaninVec(p, i) );
fprintf( pFile, ");\n" ); fprintf( pFile, ");\n" );
} }
else if ( Func == CBA_NODE_MUX ) else if ( Func == CBA_NODE_MUX )
Cba_PrsWriteVerilogMux( pFile, p, Cba_ObjFanins(p, i) ); Cba_PrsWriteVerilogMux( pFile, p, Cba_ObjFaninVec(p, i) );
else else
{ {
//char * pName = Cba_NtkStr(p, Func); //char * pName = Cba_NtkStr(p, Func);
...@@ -159,7 +159,7 @@ void Cba_PrsWriteVerilogBoxes( FILE * pFile, Cba_Ntk_t * p ) ...@@ -159,7 +159,7 @@ void Cba_PrsWriteVerilogBoxes( FILE * pFile, Cba_Ntk_t * p )
if ( Type == CBA_PRS_BOX ) // .subckt/.gate/box (formal/actual binding) if ( Type == CBA_PRS_BOX ) // .subckt/.gate/box (formal/actual binding)
{ {
fprintf( pFile, " %s %s (", Cba_ObjFuncStr(p, i), Cba_ObjInstStr(p, i) ); fprintf( pFile, " %s %s (", Cba_ObjFuncStr(p, i), Cba_ObjInstStr(p, i) );
Cba_PrsWriteVerilogArray3( pFile, p, Cba_ObjFanins(p, i) ); Cba_PrsWriteVerilogArray3( pFile, p, Cba_ObjFaninVec(p, i) );
fprintf( pFile, ");\n" ); fprintf( pFile, ");\n" );
} }
} }
......
...@@ -84,6 +84,14 @@ struct Vec_Mem_t_ ...@@ -84,6 +84,14 @@ struct Vec_Mem_t_
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline void Vec_MemAlloc_( Vec_Mem_t * p, int nEntrySize, int LogPageSze )
{
memset( p, 0, sizeof(Vec_Mem_t) );
p->nEntrySize = nEntrySize;
p->LogPageSze = LogPageSze;
p->PageMask = (1 << p->LogPageSze) - 1;
p->iPage = -1;
}
static inline Vec_Mem_t * Vec_MemAlloc( int nEntrySize, int LogPageSze ) static inline Vec_Mem_t * Vec_MemAlloc( int nEntrySize, int LogPageSze )
{ {
Vec_Mem_t * p; Vec_Mem_t * p;
......
...@@ -242,6 +242,20 @@ static inline int Vec_SetAppendS( Vec_Set_t * p, int nSize ) ...@@ -242,6 +242,20 @@ static inline int Vec_SetAppendS( Vec_Set_t * p, int nSize )
Vec_SetIncLimitS( p->pPages[p->iPageS], nWords ); Vec_SetIncLimitS( p->pPages[p->iPageS], nWords );
return Vec_SetHandCurrentS(p) - nWords; return Vec_SetHandCurrentS(p) - nWords;
} }
static inline int Vec_SetFetchH( Vec_Set_t * p, int nBytes )
{
return Vec_SetAppend(p, NULL, (nBytes + 3) >> 2);
}
static inline void * Vec_SetFetch( Vec_Set_t * p, int nBytes )
{
return (void *)Vec_SetEntry( p, Vec_SetFetchH(p, nBytes) );
}
static inline char * Vec_SetStrsav( Vec_Set_t * p, char * pName )
{
char * pStr = (char *)Vec_SetFetch( p, strlen(pName) + 1 );
strcpy( pStr, pName );
return pStr;
}
/**Function************************************************************* /**Function*************************************************************
......
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