📄 verilogannotate.cpp
字号:
// *****************************************************************************// *****************************************************************************// main.cpp//// This file contains the implementation of the standalone verilogAnnotate // application.//// *****************************************************************************// 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 istributed in any way, in any medium,// in whole or in part, without prior written permission from Cadence.//// Copyright 2003-2005 Cadence Design Systems, Inc.// All Rights Reserved.//// $Author: sailajad $// $Revision: 1.38 $// $Date: 2005/08/05 21:58:46 $// $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaVerilog.h"#include "oaUtilApp.h"using namespace oa;using namespace oaUtil;using namespace oaVerilog;// *****************************************************************************// annotateBuild// *****************************************************************************class annotateBuild : public oaBuildInfo { annotateBuild() : oaBuildInfo("verilogAnnotate", OA_BUILD_NAME, OA_BUILD_TIME, OA_BUILD_NUMBER) {} private: static annotateBuild buildInfo;};// *****************************************************************************// AnnotateAppOptions// *****************************************************************************class AnnotateAppOptions : public CommonOptions {public: AnnotateAppOptions(const oaString &usage); ~AnnotateAppOptions(); Arg<oaString> *getLibDefFileOption() {return libDef;} Arg<ArgList> *verilogOpt; Arg<ArgList> *leafLibsOpt; Arg<ArgList> *leafViewsOpt; Switch *tolerateOpt; Arg<oaString> *libDef;};// *****************************************************************************// oaVerilogAnnotateApp//// Application class to for a stand-alone application that uses the // VerilogAnnotate component. This class does not appear in a header file// because the oaVeriogAnnotate component is the public interface. See // oaVerilogAnnotate.h// *****************************************************************************class oaVerilogAnnotateApp : public oaUtil::TranslatorApp<AnnotateAppOptions> { public: oaVerilogAnnotateApp(); oaBoolean validateArgs(); void run(); private: VerilogIn reader; OptionsIn &options; Annotate annotateCallbacks; static const InputInfo input; static const OutputInfo output;};// *****************************************************************************// Initialize Static Data Members;// *****************************************************************************annotateBuild annotateBuild::buildInfo;const InputInfo oaVerilogAnnotateApp::input("Verilog", "IEEE 1364-2001");const OutputInfo oaVerilogAnnotateApp::output(FormatInfo::OpenAccess());// *****************************************************************************// AnnotateAppOptions::AnnotateAppOptions()// // This is the constructor for the AnnotateAppOptions class.// *****************************************************************************AnnotateAppOptions::AnnotateAppOptions(const oaString &usage): CommonOptions(usage){ verilogOpt = new Arg<ArgList>(*this, "verilog", "-verilog fileList", "Quoted list of input Verilog files"); leafLibsOpt = new Arg<ArgList>(*this, "leafLibs", "-leafLibs libList", "Quoted list of leaf library names"); leafViewsOpt = new Arg<ArgList>(*this, "leafViews", "[-leafViews viewList]", "Quoted list of leaf view names", ArgList(0)); tolerateOpt = new Switch(*this, "tolerate", "[-tolerate]", "Tolerate unimplemented features"); libDef = new Arg<oaString>(*this, "libDefFile", "[-libDefFile file]", "Use a specific library definitions file", LibMgrOptions::getDefaultLibDefs()); libDef->setPriority(10);}// *****************************************************************************// AnnotateAppOptions::~AnnotateAppOptions()// // This is the destructor for the AnnotateAppOptions class.// *****************************************************************************AnnotateAppOptions::~AnnotateAppOptions(){ delete verilogOpt; delete leafLibsOpt; delete leafViewsOpt; delete tolerateOpt;}// *****************************************************************************// oaVerilogAnnotateApp::oaVerilogAnnotateApp()//// This method is the constructor for the oaVerilogAnnotateApp.// *****************************************************************************oaVerilogAnnotateApp::oaVerilogAnnotateApp(): oaUtil::TranslatorApp<AnnotateAppOptions>("To annotate existing OpenAccess " "data with information from a " "Verilog netlist."), reader(_msgs), options(reader.getOptions()), annotateCallbacks(reader.getScanner(), options){ reader.setCallbacks(annotateCallbacks);}// *****************************************************************************// oaVerilogAnnotateApp::validateArgs()//// This method validates the command line arguments for the application.// *****************************************************************************oaBooleanoaVerilogAnnotateApp::validateArgs(){ oaVerilogNS vns; oaNativeNS ns; oaScalarName tmpName; oaString tmpNameStr; oaString strOptionValue; ArgList verilogFiles; _args.verilogOpt->getValue(verilogFiles); for (oaUInt4 i = 0; i < verilogFiles.getNumElements(); i++) { options.addFile(verilogFiles[i]); } ArgList leafLibs; oaBoolean first = true; _args.leafLibsOpt->getValue(leafLibs); options.clearLeafLibs(); for (oaUInt4 i = 0; i < leafLibs.getNumElements(); i++) { try { options.addLeafLib(leafLibs[i]); if (first) { options.setLibName(leafLibs[i]); first = false; } } catch (oaException &err) { const oaString dash("-"); error(dash + _args.leafLibsOpt->getName() + " \"" + leafLibs[i] + "\" : " + err.getMsg() + "\n"); return false; } } ArgList leafViews; if (_args.leafViewsOpt->isSpecified()) { _args.leafViewsOpt->getValue(leafViews); } else { leafViews.append("abstract"); } options.clearLeafViews(); for (oaUInt4 i = 0; i < leafViews.getNumElements(); i++) { try { options.addLeafView(leafViews[i]); } catch (oaException &err) { const oaString dash("-"); error(dash + _args.leafViewsOpt->getName() + " \"" + leafViews[i] + "\" : " + err.getMsg() + "\n"); return false; } } if (_args.tolerateOpt->isSpecified()) { options.enableTolerate(); } return true;}// *****************************************************************************// oaVerilogAnnotateApp::run()//// This function reads the Verilog input according to the given options.// *****************************************************************************voidoaVerilogAnnotateApp::run(){ ArgList leafLibs; _args.leafLibsOpt->getValue(leafLibs); oaNativeNS ns; oaArray<oaLib*> libs(leafLibs.getNumElements()); for (oaUInt4 i = 0; i < leafLibs.getNumElements(); i++) { libs.append(openLib(oaScalarName(ns, leafLibs[i]))); } reader.getOptions().setLibOptions(_libOptions); reader.getOptions().enableTopWarning(false); reader.parse(); LibMgr::closeAll();}// *****************************************************************************// main()//// This is the main entry point for the Verilog annotation application.// *****************************************************************************intmain(int argc, char *argv[]){ try { oaDesignInit(); } catch (oaException &excp) { fprintf(stderr, "ERROR: %s\n", (const char*) excp.getMsg()); exit(1); } oaVerilogAnnotateApp app; try { app.main(argc, argv); } catch (oaException &excp) { app.error(excp.getMsg()); } return app.getExitStatus();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -