32static void Io_NtkWriteBlifMv( FILE * pFile,
Abc_Ntk_t * pNtk );
33static void Io_NtkWriteBlifMvOne( FILE * pFile,
Abc_Ntk_t * pNtk );
34static void Io_NtkWriteBlifMvPis( FILE * pFile,
Abc_Ntk_t * pNtk );
35static void Io_NtkWriteBlifMvPos( FILE * pFile,
Abc_Ntk_t * pNtk );
36static void Io_NtkWriteBlifMvAsserts( FILE * pFile,
Abc_Ntk_t * pNtk );
37static void Io_NtkWriteBlifMvNodeFanins( FILE * pFile,
Abc_Obj_t * pNode );
38static void Io_NtkWriteBlifMvNode( FILE * pFile,
Abc_Obj_t * pNode );
39static void Io_NtkWriteBlifMvLatch( FILE * pFile,
Abc_Obj_t * pLatch );
40static void Io_NtkWriteBlifMvSubckt( FILE * pFile,
Abc_Obj_t * pNode );
41static void Io_NtkWriteBlifMvValues( FILE * pFile,
Abc_Obj_t * pNode );
63 assert( Abc_NtkIsNetlist(pNtk) );
64 assert( Abc_NtkHasBlifMv(pNtk) );
66 pFile = fopen( FileName,
"w" );
69 fprintf( stdout,
"Io_WriteBlifMv(): Cannot open the output file.\n" );
74 Io_NtkWriteBlifMv( pFile, pNtk );
80 if ( pNtkTemp == pNtk )
82 fprintf( pFile,
"\n\n" );
83 Io_NtkWriteBlifMv( pFile, pNtkTemp );
100void Io_NtkWriteBlifMv( FILE * pFile,
Abc_Ntk_t * pNtk )
102 assert( Abc_NtkIsNetlist(pNtk) );
104 fprintf( pFile,
".model %s\n", Abc_NtkName(pNtk) );
106 Io_NtkWriteBlifMvOne( pFile, pNtk );
108 if ( Abc_NtkExdc(pNtk) )
109 printf(
"Io_NtkWriteBlifMv(): EXDC is not written.\n" );
111 fprintf( pFile,
".end\n\n\n" );
125void Io_NtkWriteBlifMvOne( FILE * pFile,
Abc_Ntk_t * pNtk )
132 fprintf( pFile,
".inputs" );
133 Io_NtkWriteBlifMvPis( pFile, pNtk );
134 fprintf( pFile,
"\n" );
137 fprintf( pFile,
".outputs" );
138 Io_NtkWriteBlifMvPos( pFile, pNtk );
139 fprintf( pFile,
"\n" );
142 fprintf( pFile,
"\n" );
144 if ( Abc_ObjMvVarNum(Abc_ObjFanout0(pTerm)) > 2 )
145 fprintf( pFile,
".mv %s %d\n",
Abc_ObjName(Abc_ObjFanout0(pTerm)), Abc_ObjMvVarNum(Abc_ObjFanout0(pTerm)) );
147 if ( Abc_ObjMvVarNum(Abc_ObjFanin0(pTerm)) > 2 )
148 fprintf( pFile,
".mv %s %d\n",
Abc_ObjName(Abc_ObjFanin0(pTerm)), Abc_ObjMvVarNum(Abc_ObjFanin0(pTerm)) );
151 if ( Abc_NtkHasBlackbox( pNtk ) )
153 fprintf( pFile,
".blackbox\n" );
161 if ( !Abc_NtkIsComb(pNtk) )
163 fprintf( pFile,
"\n" );
165 Io_NtkWriteBlifMvLatch( pFile, pLatch );
166 fprintf( pFile,
"\n" );
179 if ( Abc_NtkBlackboxNum(pNtk) > 0 || Abc_NtkWhiteboxNum(pNtk) > 0 )
181 fprintf( pFile,
"\n" );
184 if ( Abc_ObjIsLatch(pNode) )
186 Io_NtkWriteBlifMvSubckt( pFile, pNode );
188 fprintf( pFile,
"\n" );
195 Extra_ProgressBarUpdate( pProgress, i, NULL );
196 Io_NtkWriteBlifMvNode( pFile, pNode );
213void Io_NtkWriteBlifMvPis( FILE * pFile,
Abc_Ntk_t * pNtk )
226 pNet = Abc_ObjFanout0(pTerm);
231 fprintf( pFile,
" \\\n" );
237 LineLength += AddedLength;
253void Io_NtkWriteBlifMvPos( FILE * pFile,
Abc_Ntk_t * pNtk )
266 pNet = Abc_ObjFanin0(pTerm);
271 fprintf( pFile,
" \\\n" );
277 LineLength += AddedLength;
293void Io_NtkWriteBlifMvLatch( FILE * pFile,
Abc_Obj_t * pLatch )
297 pNetLi = Abc_ObjFanin0( Abc_ObjFanin0(pLatch) );
298 pNetLo = Abc_ObjFanout0( Abc_ObjFanout0(pLatch) );
299 Reset = (int)(ABC_PTRUINT_T)Abc_ObjData( pLatch );
301 fprintf( pFile,
".latch" );
304 fprintf( pFile,
"\n" );
306 fprintf( pFile,
".reset %s\n",
Abc_ObjName(pNetLo) );
307 fprintf( pFile,
"%d\n", Reset-1 );
321void Io_NtkWriteBlifMvSubckt( FILE * pFile,
Abc_Obj_t * pNode )
327 fprintf( pFile,
"\n" );
329 if ( Abc_ObjMvVarNum(pTerm) > 2 )
330 fprintf( pFile,
".mv %s %d\n",
Abc_ObjName(pTerm), Abc_ObjMvVarNum(pTerm) );
332 if ( Abc_ObjMvVarNum(pTerm) > 2 )
333 fprintf( pFile,
".mv %s %d\n",
Abc_ObjName(pTerm), Abc_ObjMvVarNum(pTerm) );
335 fprintf( pFile,
".subckt %s %s", Abc_NtkName(pModel),
Abc_ObjName(pNode) );
339 fprintf( pFile,
" %s",
Abc_ObjName(Abc_ObjFanout0(pTerm)) );
340 pTerm = Abc_ObjFanin( pNode, i );
341 fprintf( pFile,
"=%s",
Abc_ObjName(Abc_ObjFanin0(pTerm)) );
345 fprintf( pFile,
" %s",
Abc_ObjName(Abc_ObjFanin0(pTerm)) );
346 pTerm = Abc_ObjFanout( pNode, i );
347 fprintf( pFile,
"=%s",
Abc_ObjName(Abc_ObjFanout0(pTerm)) );
349 fprintf( pFile,
"\n" );
364void Io_NtkWriteBlifMvNode( FILE * pFile,
Abc_Obj_t * pNode )
368 int nValues, iFanin, i;
371 fprintf( pFile,
"\n" );
375 nValues = Abc_ObjMvVarNum( pFanin );
377 fprintf( pFile,
".mv %s %d\n",
Abc_ObjName(pFanin), nValues );
383 nValues = Abc_ObjMvVarNum( Abc_ObjFanout0(pNode) );
385 fprintf( pFile,
".mv %s %d\n",
Abc_ObjName(Abc_ObjFanout0(pNode)), nValues );
389 fprintf( pFile,
".table" );
390 Io_NtkWriteBlifMvNodeFanins( pFile, pNode );
391 fprintf( pFile,
"\n" );
394 pCur = (
char *)Abc_ObjData(pNode);
397 fprintf( pFile,
".default " );
401 for ( ; *pCur; pCur++ )
403 fprintf( pFile,
"%c", *pCur );
407 iFanin = atoi( pCur+1 );
408 fprintf( pFile,
"%s",
Abc_ObjName(Abc_ObjFanin(pNode,iFanin)) );
410 while ( *pCur !=
' ' && *pCur !=
'\n' )
427void Io_NtkWriteBlifMvNodeFanins( FILE * pFile,
Abc_Obj_t * pNode )
443 AddedLength =
strlen(pName) + 1;
446 fprintf( pFile,
" \\\n" );
451 fprintf( pFile,
" %s", pName );
452 LineLength += AddedLength;
459 AddedLength =
strlen(pName) + 1;
460 if ( NameCounter && LineLength + AddedLength > 75 )
462 fprintf( pFile,
" \\\n" );
467 fprintf( pFile,
" %s", pName );
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
#define Abc_NtkForEachPo(pNtk, pPo, i)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_NtkForEachPi(pNtk, pPi, i)
#define Abc_NtkForEachCi(pNtk, pCi, i)
#define Abc_NtkForEachBox(pNtk, pObj, i)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
void Io_WriteBlifMv(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.