31 #define If_LibBoxForEachBox( p, pBox, i ) \
32 Vec_PtrForEachEntry( If_Box_t *, p->vBoxes, pBox, i ) if ( pBox == NULL ) {} else
162 char * pToken, * pName;
163 int fSeq, fBlack, fOuter;
164 int i, Id, nPis, nPos;
165 pFile = fopen( pFileName,
"rb" );
168 printf(
"Cannot open file \"%s\".\n", pFileName );
174 while ( fgets( pBuffer, nSize, pFile ) )
176 pToken =
strtok( pBuffer,
" \n\r\t" );
177 if ( pToken == NULL )
179 if ( pToken[0] ==
'.' )
181 if ( !
strcmp(pToken,
".box") )
184 pToken =
strtok( NULL,
" \n\r\t" );
187 pToken =
strtok( NULL,
" \n\r\t" );
190 pToken =
strtok( NULL,
" \n\r\t" );
191 nPis = atoi( pToken );
193 pToken =
strtok( NULL,
" \n\r\t" );
194 nPos = atoi( pToken );
196 fSeq = fBlack = fOuter = 0;
197 pToken =
strtok( NULL,
" \n\r\t" );
200 if ( !
strcmp(pToken,
"seq") )
202 else if ( !
strcmp(pToken,
"black") )
204 else if ( !
strcmp(pToken,
"outer") )
207 pToken =
strtok( NULL,
" \n\r\t" );
213 pBox =
If_BoxStart( pName, Id, nPis, nPos, fSeq, fBlack, fOuter );
219 assert( nPis > 0 && nPos > 0 );
220 for ( i = 0; i < nPis * nPos; i++ )
222 while ( pToken == NULL )
224 if ( fgets( pBuffer, nSize, pFile ) == NULL )
225 { printf(
"The table does not have enough entries.\n" ); fflush(stdout);
assert( 0 ); }
226 pToken =
strtok( pBuffer,
" \n\r\t" );
228 pBox->
pDelays[i] = (pToken[0] ==
'-') ? -1 : atoi(pToken);
229 pToken =
strtok( NULL,
" \n\r\t" );
252 static char pBuffer[1000];
253 char c, * pTemp = pBuffer;
254 while ( (c = fgetc(pFile)) != EOF )
258 while ( (c = fgetc(pFile)) != EOF )
262 if ( c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r' )
264 if ( pTemp > pBuffer )
271 return pTemp > pBuffer ? pBuffer : NULL;
278 char * pToken, * pName;
279 int i, Id, fBlack, nPis, nPos;
280 pFile = fopen( pFileName,
"rb" );
283 printf(
"Cannot open file \"%s\".\n", pFileName );
288 if ( pToken == NULL )
291 printf(
"Cannot read library name from file \"%s\".\n", pFileName );
294 if ( pToken[0] ==
'.' )
297 printf(
"Wrong box format. Please try \"read_box -e\".\n" );
312 fBlack = !atoi( pToken );
315 nPis = atoi( pToken );
318 nPos = atoi( pToken );
320 pBox =
If_BoxStart( pName, Id, nPis, nPos, 0, fBlack, 0 );
323 for ( i = 0; i < nPis * nPos; i++ )
338 fprintf( pFile,
"# Box library written by ABC on %s.\n",
Extra_TimeStamp() );
339 fprintf( pFile,
"# <Name> <ID> <Type> <I> <O>\n" );
343 for ( j = 0; j < pBox->
nPos; j++, printf(
"\n") )
344 for ( k = 0; k < pBox->
nPis; k++ )
346 fprintf( pFile,
" - " );
348 fprintf( pFile,
"%5d ", pBox->
pDelays[j * pBox->
nPis + k] );
354 pFile = fopen( pFileName,
"wb" );
357 printf(
"Cannot open file \"%s\".\n", pFileName );
379 char * pFileNameOther;
382 pFile = fopen( pFileNameOther,
"r" );
If_Box_t * If_BoxDup(If_Box_t *p)
void If_LibBoxPrint(FILE *pFile, If_LibBox_t *p)
void If_LibBoxAdd(If_LibBox_t *p, If_Box_t *pBox)
void If_BoxFree(If_Box_t *p)
static void Vec_PtrFillExtra(Vec_Ptr_t *p, int nSize, void *Fill)
If_Box_t * If_LibBoxFindBox(If_LibBox_t *p, char *pName)
#define ABC_ALLOC(type, num)
static int Vec_PtrSize(Vec_Ptr_t *p)
If_LibBox_t * If_LibBoxRead(char *pFileName)
#define If_LibBoxForEachBox(p, pBox, i)
DECLARATIONS ///.
If_Box_t * If_LibBoxReadBox(If_LibBox_t *p, int Id)
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibBox()
void If_LibBoxFree(If_LibBox_t *p)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
ABC_DLL void Abc_FrameSetLibBox(void *pLib)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
void If_LibBoxWrite(char *pFileName, If_LibBox_t *p)
char * If_LibBoxGetToken(FILE *pFile)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
If_LibBox_t * If_LibBoxStart()
#define ABC_CALLOC(type, num)
int If_LibBoxLoad(char *pFileName)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
If_LibBox_t * If_LibBoxRead2(char *pFileName)
If_Box_t * If_BoxStart(char *pName, int Id, int nPis, int nPos, int fSeq, int fBlack, int fOuter)
FUNCTION DEFINITIONS ///.
char * Abc_UtilStrsav(char *s)
If_LibBox_t * If_LibBoxDup(If_Box_t *p)
static void Vec_PtrFree(Vec_Ptr_t *p)