def main(): INFO = "Code converter from AST" VERSION = pyverilog.__version__ USAGE = "Usage: python example_codegen.py file ..." def showVersion(): print(INFO) print(VERSION) print(USAGE) sys.exit() optparser = OptionParser() optparser.add_option("-v", "--version", action="store_true", dest="showversion", default=False, help="Show the version") optparser.add_option("-I", "--include", dest="include", action="append", default=[], help="Include path") optparser.add_option("-D", dest="define", action="append", default=[], help="Macro Definition") (options, args) = optparser.parse_args() filelist = args if options.showversion: showVersion() for f in filelist: if not os.path.exists(f): raise IOError("file not found: " + f) if len(filelist) == 0: showVersion() codeparser = VerilogCodeParser(filelist, preprocess_include=options.include, preprocess_define=options.define) ast = codeparser.parse() directives = codeparser.get_directives() codegen = ASTCodeGenerator() rslt = codegen.visit(ast) print(rslt)
def main(): INFO = "Verilog ast modificator parser" VERSION = version.VERSION USAGE = "Usage: python parser.py file ..." def showVersion(): print(INFO) print(VERSION) print(USAGE) sys.exit() optparser = OptionParser() optparser.add_option( "-v", "--version", action="store_true", dest="showversion", default=False, help="Show the version" ) optparser.add_option("-o", "--output", dest="outputfile", default="out.v", help="Output File name, Default=out.v") optparser.add_option("-I", "--include", dest="include", action="append", default=[], help="Include path") (options, args) = optparser.parse_args() filelist = args if options.showversion: showVersion() for f in filelist: if not os.path.exists(f): raise IOError("file not found: " + f) if len(filelist) == 0: showVersion() codeparser = VerilogCodeParser(filelist, preprocess_include=options.include) ast = codeparser.parse() directives = codeparser.get_directives() inserter = DriveInserter("DRIVE") rslt = inserter.generate(ast) asttocode = ASTCodeGenerator() code = asttocode.visit(rslt) f = open(options.outputfile, "w") f.write(code) f.close()
def main(): INFO = "Verilog ast modificator parser" VERSION = version.VERSION USAGE = "Usage: python parser.py file ..." def showVersion(): print(INFO) print(VERSION) print(USAGE) sys.exit() optparser = OptionParser() optparser.add_option("-v","--version",action="store_true",dest="showversion", default=False,help="Show the version") optparser.add_option("-o","--output",dest="outputfile", default="out.v",help="Output File name, Default=out.v") optparser.add_option("-I","--include",dest="include",action="append", default=[],help="Include path") (options, args) = optparser.parse_args() filelist = args if options.showversion: showVersion() for f in filelist: if not os.path.exists(f): raise IOError("file not found: " + f) if len(filelist) == 0: showVersion() codeparser = VerilogCodeParser(filelist, preprocess_include=options.include) ast = codeparser.parse() directives = codeparser.get_directives() inserter = DriveInserter('DRIVE') rslt = inserter.generate(ast) asttocode = ASTCodeGenerator() code = asttocode.visit(rslt) f = open(options.outputfile, 'w') f.write(code) f.close()
def main(): INFO = "Code converter from AST" VERSION = pyverilog.utils.version.VERSION USAGE = "Usage: python example_codegen.py file ..." def showVersion(): print(INFO) print(VERSION) print(USAGE) sys.exit() optparser = OptionParser() optparser.add_option("-v","--version",action="store_true",dest="showversion", default=False,help="Show the version") optparser.add_option("-I","--include",dest="include",action="append", default=[],help="Include path") optparser.add_option("-D",dest="define",action="append", default=[],help="Macro Definition") (options, args) = optparser.parse_args() filelist = args if options.showversion: showVersion() for f in filelist: if not os.path.exists(f): raise IOError("file not found: " + f) if len(filelist) == 0: showVersion() codeparser = VerilogCodeParser(filelist, preprocess_include=options.include, preprocess_define=options.define) ast = codeparser.parse() directives = codeparser.get_directives() codegen = ASTCodeGenerator() rslt = codegen.visit(ast) print(rslt)
def test(): filelist = [codedir + 'instance_array.v'] output = 'preprocess.out' include = None define = None parser = VerilogCodeParser(filelist, preprocess_include=include, preprocess_define=define) ast = parser.parse() directives = parser.get_directives() output = StringIO() ast.show(buf=output) for lineno, directive in directives: output.write('Line %d : %s' % (lineno, directive)) rslt = output.getvalue() print(rslt) assert (expected == rslt)
def test(): filelist = [codedir + 'instance_array.v'] output = 'preprocess.out' include = None define = None parser = VerilogCodeParser(filelist, preprocess_include=include, preprocess_define=define) ast = parser.parse() directives = parser.get_directives() output = StringIO() ast.show(buf=output) for lineno, directive in directives: output.write('Line %d : %s' % (lineno, directive)) rslt = output.getvalue() print(rslt) assert(expected == rslt)
optparser.add_option("-o","--output",dest="outputfile", default="out.v",help="Output File name, Default=out.v") optparser.add_option("-I","--include",dest="include",action="append", default=[],help="Include path") (options, args) = optparser.parse_args() filelist = args if options.showversion: showVersion() for f in filelist: if not os.path.exists(f): raise IOError("file not found: " + f) if len(filelist) == 0: showVersion() codeparser = VerilogCodeParser(filelist, preprocess_include=options.include) ast = codeparser.parse() directives = codeparser.get_directives() inserter = DriveInserter('DRIVE') rslt = inserter.generate(ast) asttocode = ASTCodeGenerator() code = asttocode.visit(rslt) f = open(options.outputfile, 'w') f.write(code) f.close()