OpenCores
URL https://opencores.org/ocsvn/tcp_socket/tcp_socket/trunk

Subversion Repositories tcp_socket

[/] [tcp_socket/] [trunk/] [chips2/] [c2verilog] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jondawson
#!/usr/bin/env python
2
"""A C to Verilog compiler - Command line interface"""
3
 
4
__author__ = "Jon Dawson"
5
__copyright__ = "Copyright (C) 2012, Jonathan P Dawson"
6
__version__ = "0.1"
7
 
8
import sys
9
import os
10 4 jondawson
import subprocess
11
import atexit
12 2 jondawson
 
13
from chips.compiler.compiler import comp
14
 
15 4 jondawson
children = []
16
def cleanup():
17
    for child in children:
18
        child.terminate()
19
atexit.register(cleanup)
20
 
21 2 jondawson
if len(sys.argv) < 2 or "help" in sys.argv or "h" in sys.argv:
22
    print "Usage: c2verilog.py [options] "
23
    print
24
    print "compile options:"
25
    print "  no_reuse      : prevent register resuse"
26
    print "  no_concurrent : prevent concurrency"
27
    print "  no_initialize_memory : don't initialize memory"
28
    print "  speed : optimize for speed (defaults to area)"
29
    print
30
    print "tool options:"
31
    print "  iverilog      : compiles using the icarus verilog compiler"
32
    print "  run           : runs compiled code, used with ghdl or modelsimoptions"
33
    sys.exit(-1)
34
 
35
input_file = sys.argv[-1]
36
options = sys.argv[1:-1]
37
name, inputs, outputs, documentation = comp(input_file, options)
38
 
39
 
40 4 jondawson
 
41 2 jondawson
#run the compiled design using the simulator of your choice.
42
if "iverilog" in sys.argv:
43
    verilog_file = os.path.abspath("%s.v"%name)
44 4 jondawson
    process = subprocess.Popen(["iverilog", "-o", str(name), str(verilog_file)])
45
    children.append(process)
46
    result = process.wait()
47
    children.remove(process)
48
 
49
    if result:
50
      print "Verilog output failed to compile correctly"
51
      sys.exit(result)
52
 
53 2 jondawson
    if "run" in sys.argv:
54 4 jondawson
      process = subprocess.Popen(["vvp", str(name)])
55
      children.append(process)
56
      result = process.wait()
57
      children.remove(process)
58
      sys.exit(result)
59 2 jondawson
 
60
#Add more tools here ...

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.