⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oaverilogwritercallback.cpp

📁 openaccess与verilog互相转化时所用的源代码
💻 CPP
字号:
// *****************************************************************************// *****************************************************************************// oaVerilogWriterCallback.cpp//// This file contains the implementation of the WriterCallback class.//// *****************************************************************************// Except as specified in the OpenAccess terms of use of Cadence or Silicon// Integration Initiative, this material may not be copied, modified,// re-published, uploaded, executed, or distributed in any way, in any medium,// in whole or in part, without prior written permission from Cadence.////                Copyright 2002-2005 Cadence Design Systems, Inc.//         (c) Copyright 2003 Hewlett-Packard Development Company, LP//                           All Rights Reserved.////  $Author: shaun $//  $Revision: 1.13 $//  $Date: 2005/06/06 17:22:08 $//  $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaVerilogOutPvt.h"BEGIN_VERILOG_NAMESPACE// *****************************************************************************// WriterCallback::WriterCallback// // This is the constructor for the abstract class WriterCallback.// *****************************************************************************WriterCallback::WriterCallback(const oaString	    &fileName,			       const oaNameSpace    &nameSpace,			       const oaString	    &name, 			       const oaString	    &version,			       const oaString	    &commentPfx,			       const oaString	    &commentSfx): languageName(name),  nameSpace(nameSpace),  languageVersion(version),  commentPrefix(commentPfx),  commentSuffix(commentSfx),  indentLevel(0),  indentShift(4),  outFileName(fileName),  outFile(NULL){    memset(indent, ' ', 128 * sizeof(oaChar));    indent[indentLevel] = '\0';}// *****************************************************************************// WriterCallback::~WriterCallback// // This is the destructor for the abstract class WriterCallback.// *****************************************************************************WriterCallback::~WriterCallback(){}// *****************************************************************************// WriterCallback::openOutput()// // These functions open the output file for writing.  Any previous output file // is closed.  The first variant uses the current output file name.  The second// variant opens the given output file name.// *****************************************************************************voidWriterCallback::openOutput() {    closeOutput();    if (TranslatorOptions::useStdio(outFileName)) {	outFile = stdout;    } else {	outFile = fopen((const char*) outFileName, "w");    }    if (!outFile) {	throw oaError(oacFileNotWritable, (const char*) outFileName);    }}voidWriterCallback::openOutput(const oaString   &fileName) {    outFileName = fileName;    openOutput();}// *****************************************************************************// WriterCallback::closeOutput()// // This function closes the output file.// *****************************************************************************voidWriterCallback::closeOutput() {    if (outFile) {	fclose(outFile);	outFile = NULL;    }}// *****************************************************************************// WriterCallback::writeHeader// // This function writes header information to the output file.// *****************************************************************************voidWriterCallback::writeHeader(oaModule	&cell){    oaNativeNS	nNs;    oaString	moduleName;    oaString	viewName;    cell.getDesign()->getCellName(nNs, moduleName);    cell.getDesign()->getViewName(nNs, viewName);    write("%s %s file for cell \"%s\" view \"%s\" %s\n", getCommentPrefix(),          getLanguageName(), (const char*) moduleName, (const char*) viewName,          getCommentSuffix());    write("%s Language Version: %s %s\n", getCommentPrefix(), 	  getLanguageVersion(), getCommentSuffix());}// *****************************************************************************// WriterCallback::writeFooter// // This function wites footer information to the output file.// *****************************************************************************voidWriterCallback::writeFooter(oaModule	&cell){    write("\n");}// *****************************************************************************// WriterCallback::write//// This function writes a formatted string to the outFile file without automatic// indentation.  The format of the arguements is identical to printf().// *****************************************************************************voidWriterCallback::write(const char    *fmt,		      ...) const{    va_list args;    va_start(args, fmt);    vfprintf(outFile, fmt, args);    va_end(args);}// *****************************************************************************// WriterCallback::writeIndent//// This function records a message to the outFile file with indent.// *****************************************************************************voidWriterCallback::writeIndent(const char	*fmt,			    ...) const{    va_list args;    va_start(args, fmt);    fprintf(outFile, "%s", indent);    ::vfprintf(outFile, fmt, args);    va_end(args);}// *****************************************************************************// WriterCallback::incIndent()//// This function increments the indent string by the indentShift amount.// *****************************************************************************voidWriterCallback::incIndent(){    indent[indentLevel] = ' ';    indentLevel += indentShift;    indent[indentLevel] = '\0';}// *****************************************************************************// WriterCallback::decIndent()//// This function decrements the indent string by the indentShift amount.// *****************************************************************************voidWriterCallback::decIndent(){    indent[indentLevel] = ' ';    indentLevel -= indentShift;    indent[indentLevel] = '\0';}// *****************************************************************************// WriterCallback::setIndentShift()//// This function changes the indent shift value to the specified value.// The indent shift is the amount of indenting is done when incIndent is called.// *****************************************************************************voidWriterCallback::setIndentShift(oaUInt4	shift){    indentShift	= shift;}// *****************************************************************************// WriterCallback::getLanguageName()// WriterCallback::getLanguageVersion()// WriterCallback::getCommentPrefix()// WriterCallback::getCommentSuffix()//// These functions return the value of the corresponding variable of the// WriterCallback class.// *****************************************************************************const char*WriterCallback::getLanguageName() const{    return (const char*) languageName;}const char*WriterCallback::getLanguageVersion() const{    return (const char*) languageVersion;}const char*WriterCallback::getCommentPrefix() const{    return (const char*) commentPrefix;}const char*WriterCallback::getCommentSuffix() const{    return (const char*) commentSuffix;}END_VERILOG_NAMESPACE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -