30static int Io_WriteBenchCheckNames(
Abc_Ntk_t * pNtk );
32static int Io_WriteBenchOne( FILE * pFile,
Abc_Ntk_t * pNtk );
33static int Io_WriteBenchOneNode( FILE * pFile,
Abc_Obj_t * pNode );
35static int Io_WriteBenchLutOne( FILE * pFile,
Abc_Ntk_t * pNtk );
36static int Io_WriteBenchLutOneNode( FILE * pFile,
Abc_Obj_t * pNode,
Vec_Int_t * vTruth );
57 assert( Abc_NtkIsSopNetlist(pNtk) );
58 if ( !Io_WriteBenchCheckNames(pNtk) )
60 fprintf( stdout,
"Io_WriteBench(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
63 pFile = fopen( pFileName,
"w" );
66 fprintf( stdout,
"Io_WriteBench(): Cannot open the output file.\n" );
71 Io_WriteBenchOne( pFile, pNtk );
73 pExdc = Abc_NtkExdc( pNtk );
75 printf(
"Io_WriteBench: EXDC is not written (warning).\n" );
92int Io_WriteBenchOne( FILE * pFile,
Abc_Ntk_t * pNtk )
100 fprintf( pFile,
"INPUT(%s)\n",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
102 fprintf( pFile,
"OUTPUT(%s)\n",
Abc_ObjName(Abc_ObjFanin0(pNode)) );
104 fprintf( pFile,
"%-11s = DFF(%s)\n",
111 Extra_ProgressBarUpdate( pProgress, i, NULL );
112 Io_WriteBenchOneNode( pFile, pNode );
130int Io_WriteBenchOneNode( FILE * pFile,
Abc_Obj_t * pNode )
134 assert( Abc_ObjIsNode(pNode) );
135 nFanins = Abc_ObjFaninNum(pNode);
139 fprintf( pFile,
"%-11s",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
140 fprintf( pFile,
" = vdd\n" );
142 else if ( nFanins == 1 )
146 fprintf( pFile,
"%-11s = BUFF(",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
147 fprintf( pFile,
"%s)\n",
Abc_ObjName(Abc_ObjFanin0(pNode)) );
151 fprintf( pFile,
"%-11s = NOT(",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
152 fprintf( pFile,
"%s)\n",
Abc_ObjName(Abc_ObjFanin0(pNode)) );
157 fprintf( pFile,
"%-11s",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
158 fprintf( pFile,
" = AND(%s, ",
Abc_ObjName(Abc_ObjFanin0(pNode)) );
159 fprintf( pFile,
"%s)\n",
Abc_ObjName(Abc_ObjFanin1(pNode)) );
179 assert( Abc_NtkIsAigNetlist(pNtk) );
180 if ( !Io_WriteBenchCheckNames(pNtk) )
182 fprintf( stdout,
"Io_WriteBenchLut(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
185 pFile = fopen( pFileName,
"w" );
188 fprintf( stdout,
"Io_WriteBench(): Cannot open the output file.\n" );
193 Io_WriteBenchLutOne( pFile, pNtk );
195 pExdc = Abc_NtkExdc( pNtk );
197 printf(
"Io_WriteBench: EXDC is not written (warning).\n" );
214int Io_WriteBenchLutOne( FILE * pFile,
Abc_Ntk_t * pNtk )
223 fprintf( pFile,
"INPUT(%s)\n",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
225 fprintf( pFile,
"OUTPUT(%s)\n",
Abc_ObjName(Abc_ObjFanin0(pNode)) );
227 fprintf( pFile,
"%-11s = DFFRSE( %s, gnd, gnd, gnd, gnd )\n",
231 vMemory = Vec_IntAlloc( 10000 );
235 Extra_ProgressBarUpdate( pProgress, i, NULL );
236 Io_WriteBenchLutOneNode( pFile, pNode, vMemory );
239 Vec_IntFree( vMemory );
260 assert( Abc_ObjIsNode(pNode) );
261 nFanins = Abc_ObjFaninNum(pNode);
266 Extra_TruthNot( pTruth, pTruth, nFanins );
268 if ( Extra_TruthIsConst0(pTruth, nFanins) )
270 fprintf( pFile,
"%-11s = gnd\n",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
273 if ( Extra_TruthIsConst1(pTruth, nFanins) )
275 fprintf( pFile,
"%-11s = vdd\n",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
280 fprintf( pFile,
"%-11s = LUT 0x%d ( %s )\n",
287 fprintf( pFile,
"%-11s = LUT 0x",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
303 fprintf( pFile,
" (" );
305 fprintf( pFile,
" %s%s",
Abc_ObjName(pFanin), ((i==nFanins-1)?
"" :
",") );
306 fprintf( pFile,
" )\n" );
322int Io_WriteBenchCheckNames(
Abc_Ntk_t * pNtk )
329 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 ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
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
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
struct Hop_Obj_t_ Hop_Obj_t
int Io_WriteBenchLut(Abc_Ntk_t *pNtk, char *pFileName)
int Io_WriteBench(Abc_Ntk_t *pNtk, const char *pFileName)
FUNCTION DEFINITIONS ///.
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)