21#ifndef ABC__base__prs__prs_h
22#define ABC__base__prs__prs_h
107static inline Psr_Ntk_t * Psr_ManNtk(
Vec_Ptr_t * vPrs,
int i ) {
return i >= 0 && i < Vec_PtrSize(vPrs) ? (
Psr_Ntk_t *)Vec_PtrEntry(vPrs, i) : NULL; }
108static inline Psr_Ntk_t * Psr_ManRoot(
Vec_Ptr_t * vPrs ) {
return Psr_ManNtk(vPrs, 0); }
109static inline Abc_Nam_t * Psr_ManNameMan(
Vec_Ptr_t * vPrs ) {
return Psr_ManRoot(vPrs)->pStrs; }
111static inline int Psr_NtkId(
Psr_Ntk_t *
p ) {
return p->iModuleName; }
112static inline int Psr_NtkPioNum(
Psr_Ntk_t *
p ) {
return Vec_IntSize(&
p->vInouts); }
113static inline int Psr_NtkPiNum(
Psr_Ntk_t *
p ) {
return Vec_IntSize(&
p->vInputs); }
114static inline int Psr_NtkPoNum(
Psr_Ntk_t *
p ) {
return Vec_IntSize(&
p->vOutputs); }
115static inline int Psr_NtkBoxNum(
Psr_Ntk_t *
p ) {
return Vec_IntSize(&
p->vObjs); }
116static inline int Psr_NtkObjNum(
Psr_Ntk_t *
p ) {
return Psr_NtkPioNum(
p) + Psr_NtkPiNum(
p) + Psr_NtkPoNum(
p) + Psr_NtkBoxNum(
p); }
118static inline char * Psr_NtkName(
Psr_Ntk_t *
p ) {
return Psr_NtkStr(
p, Psr_NtkId(
p)); }
119static inline int Psr_NtkSigName(
Psr_Ntk_t *
p,
int i ) {
if (!
p->fSlices)
return i;
assert(Abc_Lit2Att2(i) ==
BAC_PRS_NAME);
return Abc_Lit2Var2(i); }
121static inline int Psr_SliceName(
Psr_Ntk_t *
p,
int h ) {
return Vec_IntEntry(&
p->vSlices, h); }
122static inline int Psr_SliceRange(
Psr_Ntk_t *
p,
int h ) {
return Vec_IntEntry(&
p->vSlices, h+1); }
124static inline int Psr_CatSize(
Psr_Ntk_t *
p,
int h ) {
return Vec_IntEntry(&
p->vConcats, h); }
125static inline int * Psr_CatArray(
Psr_Ntk_t *
p,
int h ) {
return Vec_IntEntryP(&
p->vConcats, h+1); }
126static inline Vec_Int_t * Psr_CatSignals(
Psr_Ntk_t *
p,
int h ) {
static Vec_Int_t V; V.nSize = V.nCap = Psr_CatSize(
p, h); V.pArray = Psr_CatArray(
p, h);
return &V; }
128static inline int Psr_BoxHand(
Psr_Ntk_t *
p,
int i ) {
return Vec_IntEntry(&
p->vObjs, i); }
129static inline int Psr_BoxSize(
Psr_Ntk_t *
p,
int i ) {
return Vec_IntEntry(&
p->vBoxes, Psr_BoxHand(
p, i))-2; }
130static inline int Psr_BoxIONum(
Psr_Ntk_t *
p,
int i ) {
return Psr_BoxSize(
p, i) / 2; }
131static inline int Psr_BoxNtk(
Psr_Ntk_t *
p,
int i ) {
return Vec_IntEntry(&
p->vBoxes, Psr_BoxHand(
p, i)+1); }
132static inline void Psr_BoxSetNtk(
Psr_Ntk_t *
p,
int i,
int m ) { Vec_IntWriteEntry(&
p->vBoxes, Psr_BoxHand(
p, i)+1, m); }
133static inline int Psr_BoxName(
Psr_Ntk_t *
p,
int i ) {
return Vec_IntEntry(&
p->vBoxes, Psr_BoxHand(
p, i)+2); }
134static inline int Psr_BoxIsNode(
Psr_Ntk_t *
p,
int i ) {
return!Vec_IntEntry(&
p->vBoxes, Psr_BoxHand(
p, i)+3); }
135static inline int * Psr_BoxArray(
Psr_Ntk_t *
p,
int i ) {
return Vec_IntEntryP(&
p->vBoxes, Psr_BoxHand(
p, i)+3); }
136static inline Vec_Int_t * Psr_BoxSignals(
Psr_Ntk_t *
p,
int i ) {
static Vec_Int_t V; V.nSize = V.nCap = Psr_BoxSize(
p, i); V.pArray = Psr_BoxArray(
p, i);
return &V; }
138#define Psr_ManForEachNameVec( vVec, p, pName, i ) \
139 for ( i = 0; (i < Vec_IntSize(vVec)) && ((pName) = Abc_NamStr(p->pStrs, Vec_IntEntry(vVec,i))); i++ )
141#define Psr_NtkForEachPio( p, NameId, i ) \
142 for ( i = 0; i < Psr_NtkPioNum(p) && ((NameId) = Vec_IntEntry(&p->vInouts, i)); i++ )
143#define Psr_NtkForEachPi( p, NameId, i ) \
144 for ( i = 0; i < Psr_NtkPiNum(p) && ((NameId) = Vec_IntEntry(&p->vInputs, i)); i++ )
145#define Psr_NtkForEachPo( p, NameId, i ) \
146 for ( i = 0; i < Psr_NtkPoNum(p) && ((NameId) = Vec_IntEntry(&p->vOutputs, i)); i++ )
147#define Psr_NtkForEachBox( p, vVec, i ) \
148 for ( i = 0; i < Psr_NtkBoxNum(p) && ((vVec) = Psr_BoxSignals(p, i)); i++ )
155static inline int Psr_ManErrorSet(
Psr_Man_t *
p,
char * pError,
int Value )
158 sprintf(
p->ErrorStr,
"%s", pError );
162static inline void Psr_ManErrorClear(
Psr_Man_t *
p )
164 p->ErrorStr[0] =
'\0';
167static inline int Psr_ManErrorPrint(
Psr_Man_t *
p )
169 char * pThis;
int iLine = 0;
170 if ( !
p->ErrorStr[0] )
return 1;
171 for ( pThis =
p->pBuffer; pThis < p->pCur; pThis++ )
172 iLine += (int)(*pThis ==
'\n');
173 printf(
"Line %d: %s\n", iLine,
p->ErrorStr );
178static inline void Psr_ManInitializeNtk(
Psr_Man_t *
p,
int iName,
int fSlices )
182 p->pNtk->iModuleName = iName;
183 p->pNtk->fSlices = fSlices;
185 Vec_PtrPush(
p->vNtks,
p->pNtk );
187static inline void Psr_ManFinalizeNtk(
Psr_Man_t *
p )
194static inline int Psr_NtkAddSlice(
Psr_Ntk_t *
p,
int Name,
int Range )
196 int Value = Vec_IntSize(&
p->vSlices);
197 Vec_IntPushTwo( &
p->vSlices, Name, Range );
203 if ( !(Vec_IntSize(&
p->vConcats) & 1) )
204 Vec_IntPush(&
p->vConcats, -1);
205 Value = Vec_IntSize(&
p->vConcats);
207 Vec_IntPush( &
p->vConcats, Vec_IntSize(vTemp) );
208 Vec_IntAppend( &
p->vConcats, vTemp );
211static inline void Psr_NtkAddBox(
Psr_Ntk_t *
p,
int ModName,
int InstName,
Vec_Int_t * vTemp )
214 assert( Vec_IntSize(vTemp) % 2 == 0 );
215 if ( !(Vec_IntSize(&
p->vBoxes) & 1) )
216 Vec_IntPush(&
p->vBoxes, -1);
217 Value = Vec_IntSize(&
p->vBoxes);
219 Vec_IntPush( &
p->vObjs, Value );
221 Vec_IntPush( &
p->vBoxes, Vec_IntSize(vTemp)+2 );
222 Vec_IntPush( &
p->vBoxes, ModName );
223 Vec_IntPush( &
p->vBoxes, InstName );
224 Vec_IntAppend( &
p->vBoxes, vTemp );
228static inline char * Psr_ManLoadFile(
char * pFileName,
char ** ppLimit )
231 int nFileSize, RetValue;
232 FILE * pFile = fopen( pFileName,
"rb" );
235 printf(
"Cannot open input file.\n" );
240 nFileSize = ftell( pFile );
244 pBuffer =
ABC_ALLOC(
char, nFileSize + 16 );
246 RetValue = fread( pBuffer+1, nFileSize, 1, pFile );
249 pBuffer[nFileSize + 1] =
'\n';
250 pBuffer[nFileSize + 2] =
'\0';
251 *ppLimit = pBuffer + nFileSize + 3;
254static inline Psr_Man_t * Psr_ManAlloc(
char * pFileName )
257 char * pBuffer, * pLimit;
258 pBuffer = Psr_ManLoadFile( pFileName, &pLimit );
259 if ( pBuffer == NULL )
262 p->pName = pFileName;
263 p->pBuffer = pBuffer;
267 p->vNtks = Vec_PtrAlloc( 100 );
271static inline void Psr_NtkFree(
Psr_Ntk_t *
p )
275 Vec_IntErase( &
p->vOrder );
276 Vec_IntErase( &
p->vInouts );
277 Vec_IntErase( &
p->vInputs );
278 Vec_IntErase( &
p->vOutputs );
279 Vec_IntErase( &
p->vWires );
280 Vec_IntErase( &
p->vInoutsR );
281 Vec_IntErase( &
p->vInputsR );
282 Vec_IntErase( &
p->vOutputsR );
283 Vec_IntErase( &
p->vWiresR );
284 Vec_IntErase( &
p->vSlices );
285 Vec_IntErase( &
p->vConcats );
286 Vec_IntErase( &
p->vBoxes );
287 Vec_IntErase( &
p->vObjs );
291static inline void Psr_ManVecFree(
Vec_Ptr_t * vPrs )
299static inline void Psr_ManFree(
Psr_Man_t *
p )
304 Psr_ManVecFree(
p->vNtks );
306 Vec_StrErase( &
p->vCover );
307 Vec_IntErase( &
p->vTemp );
308 Vec_IntErase( &
p->vTemp2 );
309 Vec_IntErase( &
p->vKnown );
310 Vec_IntErase( &
p->vFailed );
311 Vec_IntErase( &
p->vSucceeded );
316static inline int Psr_NtkMemory(
Psr_Ntk_t *
p )
319 nMem += Vec_IntMemory( &
p->vOrder );
320 nMem += Vec_IntMemory( &
p->vInouts );
321 nMem += Vec_IntMemory( &
p->vInputs );
322 nMem += Vec_IntMemory( &
p->vOutputs );
323 nMem += Vec_IntMemory( &
p->vWires );
324 nMem += Vec_IntMemory( &
p->vInoutsR );
325 nMem += Vec_IntMemory( &
p->vInputsR );
326 nMem += Vec_IntMemory( &
p->vOutputsR );
327 nMem += Vec_IntMemory( &
p->vWiresR );
328 nMem += Vec_IntMemory( &
p->vSlices );
329 nMem += Vec_IntMemory( &
p->vBoxes );
330 nMem += Vec_IntMemory( &
p->vConcats );
333static inline int Psr_ManMemory(
Vec_Ptr_t * vPrs )
336 int nMem = Vec_PtrMemory(vPrs);
338 nMem += Psr_NtkMemory( pNtk );
#define ABC_ALLOC(type, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
struct Psr_Ntk_t_ Psr_Ntk_t
BASIC TYPES ///.
Psr_ManType_t
INCLUDES ///.
struct Psr_Man_t_ Psr_Man_t
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
int Abc_NamMemUsed(Abc_Nam_t *p)
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
void Abc_NamDeref(Abc_Nam_t *p)
Abc_Nam_t * Abc_NamRef(Abc_Nam_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.