URL
https://opencores.org/ocsvn/tcp_socket/tcp_socket/trunk
Subversion Repositories tcp_socket
[/] [tcp_socket/] [trunk/] [chips2/] [c2verilog] - Rev 4
Compare with Previous | Blame | View Log
#!/usr/bin/env python"""A C to Verilog compiler - Command line interface"""__author__ = "Jon Dawson"__copyright__ = "Copyright (C) 2012, Jonathan P Dawson"__version__ = "0.1"import sysimport osimport subprocessimport atexitfrom chips.compiler.compiler import compchildren = []def cleanup():for child in children:child.terminate()atexit.register(cleanup)if len(sys.argv) < 2 or "help" in sys.argv or "h" in sys.argv:print "Usage: c2verilog.py [options] <input_file>"print "compile options:"print " no_reuse : prevent register resuse"print " no_concurrent : prevent concurrency"print " no_initialize_memory : don't initialize memory"print " speed : optimize for speed (defaults to area)"print "tool options:"print " iverilog : compiles using the icarus verilog compiler"print " run : runs compiled code, used with ghdl or modelsimoptions"sys.exit(-1)input_file = sys.argv[-1]options = sys.argv[1:-1]name, inputs, outputs, documentation = comp(input_file, options)#run the compiled design using the simulator of your choice.if "iverilog" in sys.argv:verilog_file = os.path.abspath("%s.v"%name)process = subprocess.Popen(["iverilog", "-o", str(name), str(verilog_file)])children.append(process)result = process.wait()children.remove(process)if result:print "Verilog output failed to compile correctly"sys.exit(result)if "run" in sys.argv:process = subprocess.Popen(["vvp", str(name)])children.append(process)result = process.wait()children.remove(process)sys.exit(result)#Add more tools here ...
