summaryrefslogtreecommitdiffstats
path: root/src/base/io/ioReadBench.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-09-26 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2007-09-26 08:01:00 -0700
commit7d7e60f2dc84393cd4c5db22d2eaf7b1fb1a79b2 (patch)
tree353d49651b06530ce1a4b1884b2f187ee3957c85 /src/base/io/ioReadBench.c
parentd62ee0a90d14fe762015906b6b3a5ad23421d390 (diff)
downloadabc-7d7e60f2dc84393cd4c5db22d2eaf7b1fb1a79b2.tar.gz
abc-7d7e60f2dc84393cd4c5db22d2eaf7b1fb1a79b2.tar.bz2
abc-7d7e60f2dc84393cd4c5db22d2eaf7b1fb1a79b2.zip
Version abc70926
Diffstat (limited to 'src/base/io/ioReadBench.c')
-rw-r--r--src/base/io/ioReadBench.c95
1 files changed, 89 insertions, 6 deletions
diff --git a/src/base/io/ioReadBench.c b/src/base/io/ioReadBench.c
index ba622e40..007147bc 100644
--- a/src/base/io/ioReadBench.c
+++ b/src/base/io/ioReadBench.c
@@ -66,6 +66,7 @@ Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck )
}
return pNtk;
}
+
/**Function*************************************************************
Synopsis []
@@ -82,7 +83,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
ProgressBar * pProgress;
Vec_Ptr_t * vTokens;
Abc_Ntk_t * pNtk;
- Abc_Obj_t * pNode;
+ Abc_Obj_t * pNode, * pNet;
Vec_Str_t * vString;
unsigned uTruth[8];
char * pType, ** ppNames, * pString;
@@ -241,11 +242,34 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
Extra_ProgressBarStop( pProgress );
Vec_StrFree( vString );
- // check if constant have been added
-// if ( pNet = Abc_NtkFindNet( pNtk, "vdd" ) )
-// Io_ReadCreateConst( pNtk, "vdd", 1 );
-// if ( pNet = Abc_NtkFindNet( pNtk, "gnd" ) )
-// Io_ReadCreateConst( pNtk, "gnd", 0 );
+ // check if constant 0 is present
+ if ( (pNet = Abc_NtkFindNet( pNtk, "gnd" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ Io_ReadCreateConst( pNtk, "gnd", 0 );
+ }
+ if ( (pNet = Abc_NtkFindNet( pNtk, "1" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ {
+ printf( "Io_ReadBenchNetwork(): Adding constant 0 fanin to non-driven net \"1\".\n" );
+ Io_ReadCreateConst( pNtk, "1", 0 );
+ }
+ }
+ // check if constant 1 is present
+ if ( (pNet = Abc_NtkFindNet( pNtk, "vdd" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ Io_ReadCreateConst( pNtk, "vdd", 1 );
+ }
+ if ( (pNet = Abc_NtkFindNet( pNtk, "2" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ {
+ printf( "Io_ReadBenchNetwork(): Adding constant 1 fanin to non-driven net \"2\".\n" );
+ Io_ReadCreateConst( pNtk, "2", 1 );
+ }
+ }
Abc_NtkFinalizeRead( pNtk );
@@ -269,6 +293,65 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
}
+/**Function*************************************************************
+
+ Synopsis [Reads initial state in BENCH format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName )
+{
+ char pBuffer[1000];
+ FILE * pFile;
+ char * pToken;
+ Abc_Obj_t * pObj;
+ int Num;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Io_ReadBenchInit(): Failed to open file \"%s\".\n", pFileName );
+ return;
+ }
+ while ( fgets( pBuffer, 999, pFile ) )
+ {
+ pToken = strtok( pBuffer, " \n\t\r" );
+ // find the latch output
+ Num = Nm_ManFindIdByName( pNtk->pManName, pToken, ABC_OBJ_BO );
+ if ( Num < 0 )
+ {
+ printf( "Io_ReadBenchInit(): Cannot find register with output %s.\n", pToken );
+ continue;
+ }
+ pObj = Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
+ if ( !Abc_ObjIsLatch(pObj) )
+ {
+ printf( "Io_ReadBenchInit(): The signal is not a register output %s.\n", pToken );
+ continue;
+ }
+ // assign the new init state
+ pToken = strtok( NULL, " \n\t\r" );
+ if ( pToken[0] == '0' )
+ Abc_LatchSetInit0( pObj );
+ else if ( pToken[0] == '1' )
+ Abc_LatchSetInit1( pObj );
+ else if ( pToken[0] == '2' )
+ Abc_LatchSetInitDc( pObj );
+ else
+ {
+ printf( "Io_ReadBenchInit(): The signal %s has unknown initial value (%s).\n",
+ Abc_ObjName(Abc_ObjFanout0(pObj)), pToken );
+ continue;
+ }
+ }
+ fclose( pFile );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////