ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioReadBlifMv.c File Reference
#include "misc/zlib/zlib.h"
#include "misc/bzlib/bzlib.h"
#include "base/abc/abc.h"
#include "misc/vec/vecPtr.h"
#include "ioAbc.h"
#include "map/mio/mio.h"
#include "base/main/main.h"
Include dependency graph for ioReadBlifMv.c:

Go to the source code of this file.

Classes

struct  Io_MvVar_t_
 
struct  Io_MvMod_t_
 
struct  Io_MvMan_t_
 
struct  buflist
 

Macros

#define IO_BLIFMV_MAXVALUES   256
 DECLARATIONS ///.
 

Typedefs

typedef struct Io_MvVar_t_ Io_MvVar_t
 
typedef struct Io_MvMod_t_ Io_MvMod_t
 
typedef struct Io_MvMan_t_ Io_MvMan_t
 
typedef struct buflist buflist
 

Functions

void Abc_NtkStartMvVars (Abc_Ntk_t *pNtk)
 DECLARATIONS ///.
 
Abc_Ntk_tIo_ReadBlifMv (char *pFileName, int fBlifMv, int fCheck)
 FUNCTION DEFINITIONS ///.
 
char * Io_MvLoadFileBz2 (char *pFileName, long *pnFileSize)
 
void Io_MvReplaceBuffersByShorts (char *p)
 

Variables

Vec_Ptr_tvGlobalLtlArray
 

Macro Definition Documentation

◆ IO_BLIFMV_MAXVALUES

#define IO_BLIFMV_MAXVALUES   256

DECLARATIONS ///.

CFile****************************************************************

FileName [ioReadBlifMv.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to read BLIF-MV file.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 8, 2007.]

Revision [

Id
ioReadBlifMv.c,v 1.00 2007/01/08 00:00:00 alanmi Exp

]

Definition at line 33 of file ioReadBlifMv.c.

Typedef Documentation

◆ buflist

typedef struct buflist buflist

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

Synopsis [Reads the file into a character buffer.]

Description []

SideEffects []

SeeAlso []

◆ Io_MvMan_t

typedef struct Io_MvMan_t_ Io_MvMan_t

Definition at line 38 of file ioReadBlifMv.c.

◆ Io_MvMod_t

typedef struct Io_MvMod_t_ Io_MvMod_t

Definition at line 37 of file ioReadBlifMv.c.

◆ Io_MvVar_t

typedef struct Io_MvVar_t_ Io_MvVar_t

Definition at line 36 of file ioReadBlifMv.c.

Function Documentation

◆ Abc_NtkStartMvVars()

void Abc_NtkStartMvVars ( Abc_Ntk_t * pNtk)
extern

DECLARATIONS ///.

CFile****************************************************************

FileName [abcBlifMv.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures to process BLIF-MV networks and AIGs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
abcBlifMv.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Starts the Mv-Var manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file abcBlifMv.c.

50{
51 Vec_Att_t * pAttMan;
52 assert( Abc_NtkMvVar(pNtk) == NULL );
53 pAttMan = Vec_AttAlloc( Abc_NtkObjNumMax(pNtk) + 1, Mem_FlexStart(), (void(*)(void*))Mem_FlexStop, NULL, NULL );
54 Vec_PtrWriteEntry( pNtk->vAttrs, VEC_ATTR_MVVAR, pAttMan );
55//printf( "allocing attr\n" );
56}
Mem_Flex_t * Mem_FlexStart()
Definition mem.c:327
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition mem.c:359
Vec_Ptr_t * vAttrs
Definition abc.h:214
#define assert(ex)
Definition util_old.h:213
@ VEC_ATTR_MVVAR
Definition vecAtt.h:52
struct Vec_Att_t_ Vec_Att_t
BASIC TYPES ///.
Definition vecAtt.h:62
Here is the caller graph for this function:

◆ Io_MvLoadFileBz2()

char * Io_MvLoadFileBz2 ( char * pFileName,
long * pnFileSize )

Definition at line 551 of file ioReadBlifMv.c.

552{
553 FILE * pFile;
554 long nFileSize = 0;
555 char * pContents;
556 BZFILE * b;
557 int bzError, RetValue;
558 struct buflist * pNext;
559 buflist * bufHead = NULL, * buf = NULL;
560
561 pFile = fopen( pFileName, "rb" );
562 if ( pFile == NULL )
563 {
564 Abc_Print( -1, "Io_MvLoadFileBz2(): The file is unavailable (absent or open).\n" );
565 return NULL;
566 }
567 b = BZ2_bzReadOpen(&bzError,pFile,0,0,NULL,0);
568 if (bzError != BZ_OK) {
569 Abc_Print( -1, "Io_MvLoadFileBz2(): BZ2_bzReadOpen() failed with error %d.\n",bzError );
570 return NULL;
571 }
572 do {
573 if (!bufHead)
574 buf = bufHead = ABC_ALLOC( buflist, 1 );
575 else
576 buf = buf->next = ABC_ALLOC( buflist, 1 );
577 nFileSize += buf->nBuf = BZ2_bzRead(&bzError,b,buf->buf,1<<20);
578 buf->next = NULL;
579 } while (bzError == BZ_OK);
580 if (bzError == BZ_STREAM_END) {
581 // we're okay
582 char * p;
583 int nBytes = 0;
584 BZ2_bzReadClose(&bzError,b);
585 p = pContents = ABC_ALLOC( char, nFileSize + 10 );
586 buf = bufHead;
587 do {
588 memcpy(p+nBytes,buf->buf,(size_t)buf->nBuf);
589 nBytes += buf->nBuf;
590// } while((buf = buf->next));
591 pNext = buf->next;
592 ABC_FREE( buf );
593 } while((buf = pNext));
594 } else if (bzError == BZ_DATA_ERROR_MAGIC) {
595 // not a BZIP2 file
596 BZ2_bzReadClose(&bzError,b);
597 fseek( pFile, 0, SEEK_END );
598 nFileSize = ftell( pFile );
599 if ( nFileSize == 0 )
600 {
601 Abc_Print( -1, "Io_MvLoadFileBz2(): The file is empty.\n" );
602 return NULL;
603 }
604 pContents = ABC_ALLOC( char, nFileSize + 10 );
605 rewind( pFile );
606 RetValue = fread( pContents, nFileSize, 1, pFile );
607 } else {
608 // Some other error.
609 Abc_Print( -1, "Io_MvLoadFileBz2(): Unable to read the compressed BLIF.\n" );
610 return NULL;
611 }
612 fclose( pFile );
613 // finish off the file with the spare .end line
614 // some benchmarks suddenly break off without this line
615 strcpy( pContents + nFileSize, "\n.end\n" );
616 *pnFileSize = nFileSize;
617 return pContents;
618}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
void BZ_API BZ2_bzReadClose(int *bzerror, BZFILE *b)
Definition bzlib.c:1154
BZFILE *BZ_API BZ2_bzReadOpen(int *bzerror, FILE *f, int verbosity, int small, void *unused, int nUnused)
Definition bzlib.c:1099
int BZ_API BZ2_bzRead(int *bzerror, BZFILE *b, void *buf, int len)
Definition bzlib.c:1173
#define BZ_DATA_ERROR_MAGIC
Definition bzlib.h:43
#define BZ_OK
Definition bzlib.h:34
#define BZ_STREAM_END
Definition bzlib.h:38
void BZFILE
Definition bzlib.h:142
Cube * p
Definition exorList.c:222
struct buflist * next
char buf[1<< 20]
char * memcpy()
char * strcpy()
VOID_HACK rewind()
#define SEEK_END
Definition zconf.h:392
Here is the call graph for this function:

◆ Io_MvReplaceBuffersByShorts()

void Io_MvReplaceBuffersByShorts ( char * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 710 of file ioReadBlifMv.c.

711{
712 if ( !strstr(p, ".gate") )
713 return;
714 char * q, * pNext, * pShort = (char *)".short"; int i;
715 for ( q = p; *q && (pNext = strstr(q, ".names")); q = pNext ) {
716 for ( i = 0; i < 6; i++ )
717 pNext[i] = pShort[i];
718 while ( *pNext && *pNext++ != '\n' );
719 if ( *pNext == 0 )
720 return;
721 while ( *pNext && *pNext != '\n' )
722 *pNext++ = ' ';
723 if ( *pNext == 0 )
724 return;
725 }
726}
char * strstr()
Here is the call graph for this function:

◆ Io_ReadBlifMv()

Abc_Ntk_t * Io_ReadBlifMv ( char * pFileName,
int fBlifMv,
int fCheck )

FUNCTION DEFINITIONS ///.

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

Synopsis [Reads the network from the BLIF or BLIF-MV file.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file ioReadBlifMv.c.

143{
144 FILE * pFile;
145 Io_MvMan_t * p;
146 Abc_Ntk_t * pNtk, * pExdc;
147 Abc_Des_t * pDesign = NULL;
148 char * pDesignName;
149 int RetValue, i;
150 char * pLtlProp;
151
152 // check that the file is available
153 pFile = fopen( pFileName, "rb" );
154 if ( pFile == NULL )
155 {
156 printf( "Io_ReadBlifMv(): The file is unavailable (absent or open).\n" );
157 return 0;
158 }
159 fclose( pFile );
160
161 // start the file reader
162 p = Io_MvAlloc();
163 p->fBlifMv = fBlifMv;
164 p->fUseReset = 1;
165 p->pFileName = pFileName;
166 p->pBuffer = Io_MvLoadFile( pFileName );
167 if ( p->pBuffer == NULL )
168 {
169 Io_MvFree( p );
170 return NULL;
171 }
172 // set the design name
173 pDesignName = Extra_FileNameGeneric( pFileName );
174 p->pDesign = Abc_DesCreate( pDesignName );
175 ABC_FREE( pDesignName );
176 // free the HOP manager
177 Hop_ManStop( (Hop_Man_t *)p->pDesign->pManFunc );
178 p->pDesign->pManFunc = NULL;
179 // prepare the file for parsing
180 Io_MvReadPreparse( p );
181 // parse interfaces of each network and construct the network
182 if ( Io_MvReadInterfaces( p ) )
183 pDesign = Io_MvParse( p );
184 if ( p->sError[0] )
185 fprintf( stdout, "%s\n", p->sError );
186 Io_MvFree( p );
187 if ( pDesign == NULL )
188 return NULL;
189// pDesign should be linked to all models of the design
190
191 // make sure that everything is okay with the network structure
192 if ( fCheck )
193 {
194 Vec_PtrForEachEntry( Abc_Ntk_t *, pDesign->vModules, pNtk, i )
195 {
196 if ( !Abc_NtkCheckRead( pNtk ) )
197 {
198 printf( "Io_ReadBlifMv: The network check has failed for model %s.\n", pNtk->pName );
199 Abc_DesFree( pDesign, NULL );
200 return NULL;
201 }
202 }
203 }
204
205//Abc_DesPrint( pDesign );
206
207 // check if there is an EXDC network
208 if ( Vec_PtrSize(pDesign->vModules) > 1 )
209 {
210 pNtk = (Abc_Ntk_t *)Vec_PtrEntry(pDesign->vModules, 0);
211 Vec_PtrForEachEntryStart( Abc_Ntk_t *, pDesign->vModules, pExdc, i, 1 )
212 if ( !strcmp(pExdc->pName, "EXDC") )
213 {
214 assert( pNtk->pExdc == NULL );
215 pNtk->pExdc = pExdc;
216 Vec_PtrRemove(pDesign->vModules, pExdc);
217 pExdc->pDesign = NULL;
218 i--;
219 }
220 else
221 pNtk = pExdc;
222 }
223
224 // detect top-level model
225 RetValue = Abc_DesFindTopLevelModels( pDesign );
226 pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pDesign->vTops, 0 );
227 if ( RetValue > 1 )
228 printf( "Warning: The design has %d root-level modules. The first one (%s) will be used.\n",
229 Vec_PtrSize(pDesign->vTops), pNtk->pName );
230
231 // extract the master network
232 pNtk->pDesign = pDesign;
233 pDesign->pManFunc = NULL;
234
235 // verify the design for cyclic dependence
236 assert( Vec_PtrSize(pDesign->vModules) > 0 );
237 if ( Vec_PtrSize(pDesign->vModules) == 1 )
238 {
239// printf( "Warning: The design is not hierarchical.\n" );
240 Abc_DesFree( pDesign, pNtk );
241 pNtk->pDesign = NULL;
242 pNtk->pSpec = Extra_UtilStrsav( pFileName );
243 }
244 else
246
247//Io_WriteBlifMv( pNtk, "_temp_.mv" );
248 if ( pNtk->pSpec == NULL )
249 pNtk->pSpec = Extra_UtilStrsav( pFileName );
250
251 vGlobalLtlArray = Vec_PtrAlloc( 100 );
252 Vec_PtrForEachEntry( char *, vGlobalLtlArray, pLtlProp, i )
253 Vec_PtrPush( pNtk->vLtlProperties, pLtlProp );
254 Vec_PtrFreeP( &vGlobalLtlArray );
255 return pNtk;
256}
ABC_DLL int Abc_DesFindTopLevelModels(Abc_Des_t *p)
Definition abcLib.c:293
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
Definition abcCheck.c:80
ABC_DLL void Abc_DesFree(Abc_Des_t *p, Abc_Ntk_t *pNtk)
Definition abcLib.c:94
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Abc_Des_t * Abc_DesCreate(char *pName)
DECLARATIONS ///.
Definition abcLib.c:45
struct Abc_Des_t_ Abc_Des_t
BASIC TYPES ///.
Definition abc.h:114
ABC_DLL int Abc_NtkIsAcyclicHierarchy(Abc_Ntk_t *pNtk)
Definition abcCheck.c:817
char * Extra_UtilStrsav(const char *s)
char * Extra_FileNameGeneric(char *FileName)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
void Hop_ManStop(Hop_Man_t *p)
Definition hopMan.c:84
Vec_Ptr_t * vGlobalLtlArray
struct Io_MvMan_t_ Io_MvMan_t
if(last==0)
Definition sparse_int.h:34
Vec_Ptr_t * vModules
Definition abc.h:225
Vec_Ptr_t * vTops
Definition abc.h:224
void * pManFunc
Definition abc.h:223
char * pName
Definition abc.h:158
Abc_Des_t * pDesign
Definition abc.h:180
Abc_Ntk_t * pExdc
Definition abc.h:201
char * pSpec
Definition abc.h:159
Vec_Ptr_t * vLtlProperties
Definition abc.h:169
int strcmp()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ vGlobalLtlArray

Vec_Ptr_t* vGlobalLtlArray

Definition at line 40 of file ioReadBlifMv.c.