mirror of
https://github.com/corundum/corundum.git
synced 2025-01-16 08:12:53 +08:00
Update generate scripts to use argparse
This commit is contained in:
parent
dcad442e7c
commit
7ea566e6d2
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_arb_mux
|
||||
|
||||
"""
|
||||
Generates an arbitrated AXI Stream mux with the specified number of ports
|
||||
|
||||
Usage: axis_arb_mux [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_arb_mux_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
@ -187,7 +155,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -197,5 +165,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_arb_mux_64
|
||||
|
||||
"""
|
||||
Generates an arbitrated AXI Stream mux with the specified number of ports
|
||||
|
||||
Usage: axis_arb_mux_64 [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_arb_mux_64_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
@ -192,7 +160,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -202,5 +170,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_crosspoint
|
||||
|
||||
"""
|
||||
Generates an AXI Stream crosspoint switch with the specified number of ports
|
||||
|
||||
Usage: axis_crosspoint [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_crosspoint_{0}x{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream crosspoint {1}...".format(ports, name))
|
||||
|
||||
@ -205,7 +173,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -215,5 +183,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_crosspoint_64
|
||||
|
||||
"""
|
||||
Generates an AXI Stream crosspoint switch with the specified number of ports
|
||||
|
||||
Usage: axis_crosspoint_64 [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_crosspoint_64_{0}x{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream crosspoint {1}...".format(ports, name))
|
||||
|
||||
@ -215,7 +183,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -225,5 +193,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_demux
|
||||
|
||||
"""
|
||||
Generates an AXI Stream demux with the specified number of ports
|
||||
|
||||
Usage: axis_demux [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_demux_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream demux {1}...".format(ports, name))
|
||||
|
||||
@ -280,7 +248,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -290,5 +258,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_demux_64
|
||||
|
||||
"""
|
||||
Generates an AXI Stream demux with the specified number of ports
|
||||
|
||||
Usage: axis_demux_64 [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_demux_64_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream demux {1}...".format(ports, name))
|
||||
|
||||
@ -294,7 +262,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -304,5 +272,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_frame_join
|
||||
|
||||
"""
|
||||
Generates an AXI Stream frame join module with a specific number of input ports
|
||||
|
||||
Usage: axis_frame_join [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_frame_join_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream frame joiner {1}...".format(ports, name))
|
||||
|
||||
@ -414,7 +382,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -424,5 +392,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_mux
|
||||
|
||||
"""
|
||||
Generates an AXI Stream mux with the specified number of ports
|
||||
|
||||
Usage: axis_mux [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_mux_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream mux {1}...".format(ports, name))
|
||||
|
||||
@ -297,7 +265,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -307,5 +275,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""axis_mux_64
|
||||
|
||||
"""
|
||||
Generates an AXI Stream mux with the specified number of ports
|
||||
|
||||
Usage: axis_mux_64 [OPTION]...
|
||||
-?, --help display this help and exit
|
||||
-p, --ports specify number of ports
|
||||
-n, --name specify module name
|
||||
-o, --output specify output file name
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import sys
|
||||
import getopt
|
||||
import argparse
|
||||
import math
|
||||
from jinja2 import Template
|
||||
|
||||
class Usage(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.strip())
|
||||
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports")
|
||||
parser.add_argument('-n', '--name', type=str, help="module name")
|
||||
parser.add_argument('-o', '--output', type=str, help="output file name")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
try:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "?n:p:o:", ["help", "name=", "ports=", "output="])
|
||||
except getopt.error as msg:
|
||||
raise Usage(msg)
|
||||
# more code, unchanged
|
||||
except Usage as err:
|
||||
print(err.msg, file=sys.stderr)
|
||||
print("for help use --help", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
ports = 4
|
||||
name = None
|
||||
out_name = None
|
||||
|
||||
# process options
|
||||
for o, a in opts:
|
||||
if o in ('-?', '--help'):
|
||||
print(__doc__)
|
||||
sys.exit(0)
|
||||
if o in ('-p', '--ports'):
|
||||
ports = int(a)
|
||||
if o in ('-n', '--name'):
|
||||
name = a
|
||||
if o in ('-o', '--output'):
|
||||
out_name = a
|
||||
generate(**args.__dict__)
|
||||
except IOError as ex:
|
||||
print(ex)
|
||||
exit(1)
|
||||
|
||||
def generate(ports=4, name=None, output=None):
|
||||
if name is None:
|
||||
name = "axis_mux_64_{0}".format(ports)
|
||||
|
||||
if out_name is None:
|
||||
out_name = name + ".v"
|
||||
if output is None:
|
||||
output = name + ".v"
|
||||
|
||||
print("Opening file '%s'..." % out_name)
|
||||
print("Opening file '{0}'...".format(output))
|
||||
|
||||
try:
|
||||
out_file = open(out_name, 'w')
|
||||
except Exception as ex:
|
||||
print("Error opening \"%s\": %s" %(out_name, ex.strerror), file=sys.stderr)
|
||||
exit(1)
|
||||
output_file = open(output, 'w')
|
||||
|
||||
print("Generating {0} port AXI Stream mux {1}...".format(ports, name))
|
||||
|
||||
@ -313,7 +281,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -323,5 +291,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user