30static int Io_WriteSmvCheckNames(
Abc_Ntk_t * pNtk );
32static int Io_WriteSmvOne( FILE * pFile,
Abc_Ntk_t * pNtk );
33static int Io_WriteSmvOneNode( FILE * pFile,
Abc_Obj_t * pNode );
45static char *cleanUNSAFE(
const char *s )
48 static char buffer[1024];
51 for (t = buffer; *t != 0; ++t) *t = (*t ==
'|') ?
'_' : *t;
55static int hasPrefix(
const char *needle,
const char *haystack)
75 assert( Abc_NtkIsSopNetlist(pNtk) );
76 if ( !Io_WriteSmvCheckNames(pNtk) )
78 fprintf( stdout,
"Io_WriteSmv(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the SMV format. Use \"short_names\".\n" );
81 pFile = fopen( pFileName,
"w" );
84 fprintf( stdout,
"Io_WriteSmv(): Cannot open the output file.\n" );
89 Io_WriteSmvOne( pFile, pNtk );
91 pExdc = Abc_NtkExdc( pNtk );
93 printf(
"Io_WriteSmv: EXDC is not written (warning).\n" );
110int Io_WriteSmvOne( FILE * pFile,
Abc_Ntk_t * pNtk )
117 fprintf( pFile,
"MODULE main\n");
118 fprintf ( pFile,
"\n" );
120 fprintf( pFile,
"VAR -- inputs\n");
122 fprintf( pFile,
" %s : boolean;\n",
124 fprintf ( pFile,
"\n" );
126 fprintf( pFile,
"VAR -- state variables\n");
128 fprintf( pFile,
" %s : boolean;\n",
129 cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode)))) );
130 fprintf ( pFile,
"\n" );
139 fprintf( pFile,
"DEFINE\n");
143 Extra_ProgressBarUpdate( pProgress, i, NULL );
144 Io_WriteSmvOneNode( pFile, pNode );
147 fprintf ( pFile,
"\n" );
149 fprintf( pFile,
"ASSIGN\n");
152 int Reset = (int)(ABC_PTRUINT_T)Abc_ObjData( pNode );
158 fprintf( pFile,
" init(%s) := %d;\n",
159 cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode)))),
162 fprintf( pFile,
" next(%s) := ",
163 cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode)))) );
164 fprintf( pFile,
"%s;\n",
165 cleanUNSAFE(
Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pNode)))) );
168 fprintf ( pFile,
"\n" );
171 const char *n = cleanUNSAFE(
Abc_ObjName(Abc_ObjFanin0(pNode)));
173 if (hasPrefix(
"assume_fair_", n))
175 fprintf( pFile,
"FAIRNESS %s;\n", n );
177 else if (hasPrefix(
"Assert_", n) ||
178 hasPrefix(
"assert_safety_", n))
180 fprintf( pFile,
"INVARSPEC %s;\n", n );
182 else if (hasPrefix(
"assert_fair_", n))
184 fprintf( pFile,
"LTLSPEC G F %s;\n", n );
202int Io_WriteSmvOneNode( FILE * pFile,
Abc_Obj_t * pNode )
206 assert( Abc_ObjIsNode(pNode) );
207 nFanins = Abc_ObjFaninNum(pNode);
211 fprintf( pFile,
" %s", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(pNode)) ) );
212 fprintf( pFile,
" := 1;\n" );
214 else if ( nFanins == 1 )
218 fprintf( pFile,
" %s := ", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(pNode))) );
219 fprintf( pFile,
"%s;\n", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanin0(pNode))) );
223 fprintf( pFile,
" %s := !", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(pNode))) );
224 fprintf( pFile,
"%s;\n", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanin0(pNode))) );
229 fprintf( pFile,
" %s", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanout0(pNode))) );
230 fprintf( pFile,
" := %s & ", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanin0(pNode))) );
231 fprintf( pFile,
"%s;\n", cleanUNSAFE(
Abc_ObjName(Abc_ObjFanin1(pNode))) );
247int Io_WriteSmvCheckNames(
Abc_Ntk_t * pNtk )
254 if ( *pName ==
'(' || *pName ==
')' )
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL int Abc_NodeIsBuf(Abc_Obj_t *pNode)
#define Abc_NtkForEachPo(pNtk, pPo, i)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
int Io_WriteSmv(Abc_Ntk_t *pNtk, char *pFileName)
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)