Line 5... |
Line 5... |
__copyright__ = "Copyright (C) 2012, Jonathan P Dawson"
|
__copyright__ = "Copyright (C) 2012, Jonathan P Dawson"
|
__version__ = "0.1"
|
__version__ = "0.1"
|
|
|
import sys
|
import sys
|
import os
|
import os
|
|
import subprocess
|
|
import atexit
|
|
|
from chips.compiler.compiler import comp
|
from chips.compiler.compiler import comp
|
|
|
|
children = []
|
|
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:
|
if len(sys.argv) < 2 or "help" in sys.argv or "h" in sys.argv:
|
print "Usage: c2verilog.py [options] "
|
print "Usage: c2verilog.py [options] "
|
print
|
print
|
print "compile options:"
|
print "compile options:"
|
print " no_reuse : prevent register resuse"
|
print " no_reuse : prevent register resuse"
|
Line 27... |
Line 35... |
input_file = sys.argv[-1]
|
input_file = sys.argv[-1]
|
options = sys.argv[1:-1]
|
options = sys.argv[1:-1]
|
name, inputs, outputs, documentation = comp(input_file, options)
|
name, inputs, outputs, documentation = comp(input_file, options)
|
|
|
|
|
|
|
#run the compiled design using the simulator of your choice.
|
#run the compiled design using the simulator of your choice.
|
if "iverilog" in sys.argv:
|
if "iverilog" in sys.argv:
|
import os
|
|
import tempfile
|
|
import shutil
|
|
verilog_file = os.path.abspath("%s.v"%name)
|
verilog_file = os.path.abspath("%s.v"%name)
|
#tempdir = tempfile.mkdtemp()
|
process = subprocess.Popen(["iverilog", "-o", str(name), str(verilog_file)])
|
#os.chdir(tempdir)
|
children.append(process)
|
os.system("iverilog -o %s %s"%(name, verilog_file))
|
result = process.wait()
|
if "run" in sys.argv:
|
children.remove(process)
|
result = os.system("vvp %s"%name)
|
|
if result:
|
if result:
|
sys.exit(1)
|
print "Verilog output failed to compile correctly"
|
else:
|
sys.exit(result)
|
sys.exit(0)
|
|
#shutil.rmtree(tempdir)
|
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 ...
|
#Add more tools here ...
|