diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2021-05-08 20:10:44 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2021-05-08 20:10:44 -0700 |
commit | 76bed2055cc171109a86bf56c6da00aa4d251a30 (patch) | |
tree | d4453ed54592f0836e8a4af12188bcb25299eb16 /src/misc/vec | |
parent | 17476146caa0184f908cfc908520375d788a8ba1 (diff) | |
download | abc-76bed2055cc171109a86bf56c6da00aa4d251a30.tar.gz abc-76bed2055cc171109a86bf56c6da00aa4d251a30.tar.bz2 abc-76bed2055cc171109a86bf56c6da00aa4d251a30.zip |
Updating LUT synthesis code.
Diffstat (limited to 'src/misc/vec')
-rw-r--r-- | src/misc/vec/vecWrd.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/misc/vec/vecWrd.h b/src/misc/vec/vecWrd.h index 663b7a88..9fa82f2d 100644 --- a/src/misc/vec/vecWrd.h +++ b/src/misc/vec/vecWrd.h @@ -1330,6 +1330,63 @@ static inline Vec_Wrd_t * Vec_WrdReadHex( char * pFileName, int * pnWords, int f return p; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Vec_WrdDumpBin( char * pFileName, Vec_Wrd_t * p, int fVerbose ) +{ + int RetValue; + FILE * pFile = fopen( pFileName, "wb" ); + if ( pFile == NULL ) + { + printf( "Cannot open file \"%s\" for writing.\n", pFileName ); + return; + } + RetValue = fwrite( Vec_WrdArray(p), 1, 8*Vec_WrdSize(p), pFile ); + fclose( pFile ); + if ( RetValue != 8*Vec_WrdSize(p) ) + printf( "Error reading data from file.\n" ); + if ( fVerbose ) + printf( "Written %d words of simulation data into file \"%s\".\n", Vec_WrdSize(p), pFileName ); +} +static inline Vec_Wrd_t * Vec_WrdReadBin( char * pFileName, int fVerbose ) +{ + Vec_Wrd_t * p = NULL; int nSize, RetValue; + FILE * pFile = fopen( pFileName, "rb" ); + if ( pFile == NULL ) + { + printf( "Cannot open file \"%s\" for reading.\n", pFileName ); + return NULL; + } + fseek( pFile, 0, SEEK_END ); + nSize = ftell( pFile ); + if ( nSize % 8 > 0 ) + { + printf( "Cannot read file with simulation data that is not aligned at 8 bytes (remainder = %d).\n", nSize % 8 ); + fclose( pFile ); + return NULL; + } + else + { + rewind( pFile ); + p = Vec_WrdStart( nSize/8 ); + RetValue = fread( Vec_WrdArray(p), 1, nSize, pFile ); + fclose( pFile ); + if ( RetValue != nSize ) + printf( "Error reading data from file.\n" ); + if ( fVerbose ) + printf( "Read %d words of simulation data from file \"%s\".\n", nSize/8, pFileName ); + return p; + } +} ABC_NAMESPACE_HEADER_END |