65 printf(
"Io_WriteVerilog(): Can produce Verilog for mapped or AIG netlists only.\n" );
69 pFile = fopen( pFileName,
"w" );
72 fprintf( stdout,
"Io_WriteVerilog(): Cannot open the output file \"%s\".\n", pFileName );
78 fprintf( pFile,
"\n" );
89 if ( pNetlist == pNtk )
91 fprintf( pFile,
"\n" );
100 fprintf( pFile,
"\n" );
122 fprintf( pFile,
"clock, " );
124 fprintf( pFile,
"\n " );
128 fprintf( pFile,
",\n " );
132 fprintf( pFile,
" );\n" );
135 fprintf( pFile,
" input clock;\n" );
140 fprintf( pFile,
" input " );
142 fprintf( pFile,
";\n" );
146 fprintf( pFile,
" output" );
148 fprintf( pFile,
";\n" );
155 fprintf( pFile,
" reg" );
157 fprintf( pFile,
";\n" );
161 fprintf( pFile,
" wire" );
163 fprintf( pFile,
";\n" );
172 fprintf( pFile,
"endmodule\n\n" );
203 fprintf( pFile,
"\n " );
209 LineLength += AddedLength;
258 fprintf( pFile,
"\n " );
264 LineLength += AddedLength;
271 printf(
"Io_WriteVerilogPos(): Omitted %d feedthrough nets from output list of module (e.g. %s).\n", nskip,
Abc_ObjName(pSkip) );
290 Abc_Obj_t * pObj, * pNet, * pBox, * pTerm;
315 fprintf( pFile,
"\n " );
321 LineLength += AddedLength;
332 fprintf( pFile,
"\n " );
338 LineLength += AddedLength;
353 fprintf( pFile,
"\n " );
359 LineLength += AddedLength;
372 fprintf( pFile,
"\n " );
378 LineLength += AddedLength;
382 assert( Counter == nNodes );
419 fprintf( pFile,
"\n " );
425 LineLength += AddedLength;
450 fprintf( pFile,
" always @ (posedge clock) begin\n" );
456 fprintf( pFile,
" end\n" );
464 fprintf( pFile,
" initial begin\n" );
472 fprintf( pFile,
" end\n" );
492 int i, k,
Counter, nDigits, Length;
502 fprintf( pFile,
" %s box%0*d", pNtkBox->
pName, nDigits, Counter++ );
503 fprintf( pFile,
"(" );
514 fprintf( pFile,
");\n" );
532 fprintf( pFile,
" %-*s g%0*d", Length,
Mio_GateReadName(pGate), nDigits, Counter++ );
533 fprintf( pFile,
"(" );
542 fprintf( pFile,
");\n" );
557 fprintf( pFile,
";\n" );
620 static char Buffer[500];
624 if ( !(Length == 1 && (pName[0] ==
'0' || pName[0] ==
'1')) )
626 for ( i = 0; i < Length; i++ )
627 if ( !((pName[i] >=
'a' && pName[i] <=
'z') ||
628 (pName[i] >=
'A' && pName[i] <=
'Z') ||
629 (pName[i] >=
'0' && pName[i] <=
'9') || pName[i] ==
'_') )
636 for ( i = 0; i < Length; i++ )
637 Buffer[i+1] = pName[i];
638 Buffer[Length+1] =
' ';
639 Buffer[Length+2] = 0;
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
static int Abc_LatchInit(Abc_Obj_t *pLatch)
static void Io_WriteVerilogPis(FILE *pFile, Abc_Ntk_t *pNtk, int Start)
static int Io_WriteVerilogWiresCount(Abc_Ntk_t *pNtk)
static Vec_Vec_t * Vec_VecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
static int Abc_NtkBoxNum(Abc_Ntk_t *pNtk)
static void Io_WriteVerilogPos(FILE *pFile, Abc_Ntk_t *pNtk, int Start)
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
char * Mio_GateReadOutName(Mio_Gate_t *pGate)
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
char * Mio_PinReadName(Mio_Pin_t *pPin)
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
static void Io_WriteVerilogLatches(FILE *pFile, Abc_Ntk_t *pNtk)
static void Io_WriteVerilogObjects(FILE *pFile, Abc_Ntk_t *pNtk)
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
static void Vec_VecFree(Vec_Vec_t *p)
static void Io_WriteVerilogWires(FILE *pFile, Abc_Ntk_t *pNtk, int Start)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
void Io_WriteVerilog(Abc_Ntk_t *pNtk, char *pFileName)
FUNCTION DEFINITIONS ///.
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
static int Abc_NtkHasBlackbox(Abc_Ntk_t *pNtk)
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
static ABC_NAMESPACE_IMPL_START void Io_WriteVerilogInt(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
static int Abc_NtkIsAigNetlist(Abc_Ntk_t *pNtk)
static int Abc_Base10Log(unsigned n)
#define ABC_NAMESPACE_IMPL_END
STRUCTURE DEFINITIONS ///.
#define Abc_NtkForEachLatch(pNtk, pObj, i)
static void Io_WriteVerilogRegs(FILE *pFile, Abc_Ntk_t *pNtk, int Start)
#define Abc_NtkForEachBox(pNtk, pObj, i)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
static int Abc_NtkIsMappedNetlist(Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
static char * Io_WriteVerilogGetName(char *pName)
int Mio_LibraryReadGateNameMax(Mio_Library_t *pLib)
#define Abc_NtkForEachPo(pNtk, pPo, i)
static Abc_Obj_t * Abc_ObjFanout(Abc_Obj_t *pObj, int i)
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
char * Mio_GateReadName(Mio_Gate_t *pGate)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
#define Abc_NtkForEachPi(pNtk, pPi, i)
void Hop_ObjPrintVerilog(FILE *pFile, Hop_Obj_t *pObj, Vec_Vec_t *vLevels, int Level)