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

📄 oa2verilog.cpp

📁 openaccess与verilog互相转化时所用的源代码
💻 CPP
字号:
// *****************************************************************************// main.cpp//// This	file contains the implementation of the standalone oa2verilog// 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	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: sailajad $//  $Revision: 1.47 $//  $Date: 2005/08/05 21:58:13 $//  $State: Exp $// *****************************************************************************// *****************************************************************************#include "oaVerilog.h"#include "oaUtilApp.h"using namespace oa;using namespace oaUtil;using namespace oaVerilog;// *****************************************************************************// oa2verilogBuild// *****************************************************************************class oa2verilogBuild : public oaBuildInfo {			    oa2verilogBuild() : oaBuildInfo("oa2verilog",							    OA_BUILD_NAME,							    OA_BUILD_TIME,							    OA_BUILD_NUMBER) {}  private:    static oa2verilogBuild  buildInfo;};// *****************************************************************************// oaVerilogOutApp//// Application class to	for a stand-alone application that uses	the VerilogOut// component.  This class does not appear in a header file because the// oaVeriogOut component is the public interface. See VerilogOut.h// *****************************************************************************class oaVerilogOutApp : public oaUtil::TranslatorApp<WriterOptions> {  public:			    oaVerilogOutApp();    oaBoolean		    validateArgs();    void		    run();  private:    OptionsOut		    &options;    VerilogOut		    writer;    Arg<oaString>	    globalsOpt;    Arg<oaString>	    tieHighOpt;    Arg<oaString>	    tieLowOpt;    Switch		    excludeLeafOpt;    Arg<oaString>	    outputOpt;    Switch		    recursiveOpt;    Arg<oaString>	    leafFileOpt;    Switch		    literalOpt;    Switch		    noStoppingOpt;    static const InputInfo  input;    static const OutputInfo output;};// *****************************************************************************// Initialize Static Data Members;// *****************************************************************************oa2verilogBuild	    oa2verilogBuild::buildInfo;const InputInfo	    oaVerilogOutApp::input(FormatInfo::OpenAccess());const OutputInfo    oaVerilogOutApp::output("Verilog", "IEEE 1364-2001");// *****************************************************************************// oaVerilogOutApp::oaVerilogOutApp()//// This	method is the constructor for the oaVerilogInApp.// *****************************************************************************oaVerilogOutApp::oaVerilogOutApp():   TranslatorApp<WriterOptions>("Translate an OpenAccess database to Verilog"),    writer(_msgs),    options(writer.getOptions()),    globalsOpt(_args, "globals", "[-globals module]", 	       "Global net module name", "globals"),    tieHighOpt(_args, "tieHigh", "[-tieHigh net]", 	       "Tie high net name", "tie1"),    tieLowOpt(_args, "tieLow", "[-tieLow net]", "Tie low net name", "tie0"),    excludeLeafOpt(_args, "excludeLeaf", "[-excludeLeaf]", 		   "Do not produce leaf modules"),    outputOpt(_args, "verilog", "-verilog file", "Output Verilog file"),    recursiveOpt(_args, "recursive", "[-recursive]", 		 "Write module definitions for all module instance masters in "		 "the hierarchy"),    leafFileOpt(_args, "leafFile", "[-leafFile file]", 		"Separate file for leaf modules", "leafModules.v"),    literalOpt(_args, "literal", "[-literal]",	       "Write module interfaces literally. "	       "Does not preserve original interface"),    noStoppingOpt(_args, "noStopping", "[-noStopping]",		  "Write module definitions for all module and design "		  "instance masters in the hierarchy.  This option "		  "implies -recursive and cannot be used -excludeLeaf "		  "or -leafFile"){}// *****************************************************************************// oaVerilogOutApp::validateArgs()//// This	method validates the command line arguments for the application.// *****************************************************************************oaBooleanoaVerilogOutApp::validateArgs(){    oaVerilogNS	    vns;    oaNativeNS	    ns;    oaScalarName    tmpName;    oaString	    tmpNameStr;    oaString	    strOptionValue;    const oaString  dash("-");    try {	_args.getLibOption()->getValue(strOptionValue);	options.setLibName(strOptionValue);    }    catch (oaException &err) {	error(dash + _args.getLibOption()->getName() + " \"" 	      + strOptionValue + "\" : " + err.getMsg() + "\n");	return false;    }    try {	_args.getCellOption()->getValue(strOptionValue);	options.setCellName(strOptionValue);    }    catch (oaException &err) {	error(dash + _args.getCellOption()->getName() + " \"" 	      + strOptionValue + "\" : " + err.getMsg() + "\n");	return false;    }    try {	_args.getViewOption()->getValue(strOptionValue);	options.setViewName(strOptionValue);    }    catch (oaException &err) {	error(dash + _args.getViewOption()->getName() + " \"" 	      + strOptionValue + "\" : " + err.getMsg() + "\n");	return false;    }    if (excludeLeafOpt.isSpecified()) {	options.enableProduceLeaf(false);    }    globalsOpt.getValue(strOptionValue);    options.setGlobalModuleName(strOptionValue);    if (leafFileOpt.getValue(strOptionValue)) {	options.setLeafFile(strOptionValue);    }    outputOpt.getValue(strOptionValue);    options.setFileName(strOptionValue);    if (TranslatorOptions::useStdio(outputOpt.getValue())) {	_msgs.setOutFile(NULL);    }    if (recursiveOpt.isSpecified()) {	options.enableRecursive();    }    if (noStoppingOpt.isSpecified()) {	options.enableRecursiveDesign();	options.enableProduceLeaf(false);    }    oaScalarName	netName;    try {	tieHighOpt.getValue(strOptionValue);	netName.init(vns, strOptionValue);	options.setTieHighNet(netName);    }    catch (oaException	&err) {	error(dash + tieHighOpt.getName() + " \"" + strOptionValue + "\" : " 	      + err.getMsg() + "\n");	return false;    }    try {	tieLowOpt.getValue(strOptionValue);	netName.init(vns, strOptionValue);	options.setTieLowNet(netName);    }    catch (oaException	&err) {	error(dash + tieLowOpt.getName() + " \"" + strOptionValue + "\" : " 	      + err.getMsg() + "\n");	return false;    }    if (literalOpt.isSpecified()) {	options.enablePreserveInterface(false);    }    if (noStoppingOpt.isSpecified() && leafFileOpt.isSpecified()) {	error(dash + noStoppingOpt.getName() + " cannot be used with "	      + dash + leafFileOpt.getName());	return false;    }    if (noStoppingOpt.isSpecified() && excludeLeafOpt.isSpecified()) {	error(dash + noStoppingOpt.getName() + " cannot be used with "	      + dash + excludeLeafOpt.getName());	return false;    }    return true;}// *****************************************************************************// oaVerilogInApp::run()//// This	function writes the Verilog output according to the given options.// *****************************************************************************voidoaVerilogOutApp::run(){    oaVerilogNS	    vns;    oaScalarName    libN(options.getLibName());    oaLib	    *lib = openLib(libN);    writer.getOptions().setLibOptions(_libOptions);    writer.write();    LibMgr::closeAll();}// *****************************************************************************// main()//// main	function for the 'oa2verilog' translator.// *****************************************************************************intmain(int    argc,      char   *argv[]){    try {	oaDesignInit();    }    catch (oaException	&excp) {	fprintf(stderr, "ERROR: %s\n", (const char*) excp.getMsg());	exit(1);    }    oaVerilogOutApp 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 + -