ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioReadBench.c File Reference
#include "ioAbc.h"
Include dependency graph for ioReadBench.c:

Go to the source code of this file.

Functions

Abc_Ntk_tIo_ReadBench (char *pFileName, int fCheck)
 FUNCTION DEFINITIONS ///.
 
void Io_ReadBenchInit (Abc_Ntk_t *pNtk, char *pFileName)
 

Function Documentation

◆ Io_ReadBench()

Abc_Ntk_t * Io_ReadBench ( char * pFileName,
int fCheck )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Reads the network from a BENCH file.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ioReadBench.c.

48{
50 Abc_Ntk_t * pNtk;
51
52 // start the file
53 p = Extra_FileReaderAlloc( pFileName, "#", "\n\r", " \t,()=" );
54 if ( p == NULL )
55 return NULL;
56
57 // read the network
58 pNtk = Io_ReadBenchNetwork( p );
60 if ( pNtk == NULL )
61 return NULL;
62
63 // make sure that everything is okay with the network structure
64 if ( fCheck && !Abc_NtkCheckRead( pNtk ) )
65 {
66 printf( "Io_ReadBench: The network check has failed.\n" );
67 Abc_NtkDelete( pNtk );
68 return NULL;
69 }
70 return pNtk;
71}
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition abcCheck.c:80
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
Cube * p
Definition exorList.c:222
Extra_FileReader_t * Extra_FileReaderAlloc(char *pFileName, char *pCharsComment, char *pCharsStop, char *pCharsClean)
FUNCTION DEFINITIONS ///.
struct Extra_FileReader_t_ Extra_FileReader_t
Definition extra.h:135
void Extra_FileReaderFree(Extra_FileReader_t *p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_ReadBenchInit()

void Io_ReadBenchInit ( Abc_Ntk_t * pNtk,
char * pFileName )

Function*************************************************************

Synopsis [Reads initial state in BENCH format.]

Description []

SideEffects []

SeeAlso []

Definition at line 336 of file ioReadBench.c.

337{
338 char pBuffer[1000];
339 FILE * pFile;
340 char * pToken;
341 Abc_Obj_t * pObj;
342 int Num;
343 pFile = fopen( pFileName, "r" );
344 if ( pFile == NULL )
345 {
346 printf( "Io_ReadBenchInit(): Failed to open file \"%s\".\n", pFileName );
347 return;
348 }
349 while ( fgets( pBuffer, 999, pFile ) )
350 {
351 pToken = strtok( pBuffer, " \n\t\r" );
352 // find the latch output
353 Num = Nm_ManFindIdByName( pNtk->pManName, pToken, ABC_OBJ_BO );
354 if ( Num < 0 )
355 {
356 printf( "Io_ReadBenchInit(): Cannot find register with output %s.\n", pToken );
357 continue;
358 }
359 pObj = Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
360 if ( !Abc_ObjIsLatch(pObj) )
361 {
362 printf( "Io_ReadBenchInit(): The signal is not a register output %s.\n", pToken );
363 continue;
364 }
365 // assign the new init state
366 pToken = strtok( NULL, " \n\t\r" );
367 if ( pToken[0] == '0' )
368 Abc_LatchSetInit0( pObj );
369 else if ( pToken[0] == '1' )
370 Abc_LatchSetInit1( pObj );
371 else if ( pToken[0] == '2' )
372 Abc_LatchSetInitDc( pObj );
373 else
374 {
375 printf( "Io_ReadBenchInit(): The signal %s has unknown initial value (%s).\n",
376 Abc_ObjName(Abc_ObjFanout0(pObj)), pToken );
377 continue;
378 }
379 }
380 fclose( pFile );
381}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
@ ABC_OBJ_BO
Definition abc.h:92
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
Definition nmApi.c:219
Nm_Man_t * pManName
Definition abc.h:160
char * strtok()
Here is the call graph for this function:
Here is the caller graph for this function: