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
15fda58c7c
commit
2a59c7db1c
@ -1,72 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""eth_arb_mux
|
||||
|
||||
"""
|
||||
Generates an arbitrated Ethernet mux with the specified number of ports
|
||||
|
||||
Usage: eth_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 = "eth_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))
|
||||
print("Generating {0} port Ethernet arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
select_width = int(math.ceil(math.log(ports, 2)))
|
||||
|
||||
@ -204,7 +172,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -214,5 +182,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,72 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""eth_arb_mux_64
|
||||
|
||||
"""
|
||||
Generates an arbitrated Ethernet mux with the specified number of ports
|
||||
|
||||
Usage: eth_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 = "eth_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))
|
||||
print("Generating {0} port Ethernet arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
select_width = int(math.ceil(math.log(ports, 2)))
|
||||
|
||||
@ -208,7 +176,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -218,5 +186,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""eth_demux
|
||||
|
||||
"""
|
||||
Generates an Ethernet demux with the specified number of ports
|
||||
|
||||
Usage: eth_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 = "eth_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 Ethernet demux {1}...".format(ports, name))
|
||||
|
||||
@ -337,7 +305,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -347,5 +315,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""eth_demux_64
|
||||
|
||||
"""
|
||||
Generates an Ethernet demux with the specified number of ports
|
||||
|
||||
Usage: eth_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 = "eth_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 Ethernet demux {1}...".format(ports, name))
|
||||
|
||||
@ -350,7 +318,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -360,5 +328,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""eth_mux
|
||||
|
||||
"""
|
||||
Generates an Ethernet mux with the specified number of ports
|
||||
|
||||
Usage: eth_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 = "eth_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 Ethernet mux {1}...".format(ports, name))
|
||||
|
||||
@ -361,7 +329,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -371,5 +339,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""eth_mux_64
|
||||
|
||||
"""
|
||||
Generates an Ethernet mux with the specified number of ports
|
||||
|
||||
Usage: eth_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 = "eth_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 Ethernet mux {1}...".format(ports, name))
|
||||
|
||||
@ -376,7 +344,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -386,5 +354,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,72 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""ip_arb_mux
|
||||
|
||||
"""
|
||||
Generates an arbitrated IP mux with the specified number of ports
|
||||
|
||||
Usage: ip_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 = "ip_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))
|
||||
print("Generating {0} port IP arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
select_width = int(math.ceil(math.log(ports, 2)))
|
||||
|
||||
@ -256,7 +224,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -266,5 +234,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,72 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""ip_arb_mux_64
|
||||
|
||||
"""
|
||||
Generates an arbitrated IP mux with the specified number of ports
|
||||
|
||||
Usage: ip_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 = "ip_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))
|
||||
print("Generating {0} port IP arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
select_width = int(math.ceil(math.log(ports, 2)))
|
||||
|
||||
@ -260,7 +228,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -270,5 +238,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""ip_demux
|
||||
|
||||
"""
|
||||
Generates an IP demux with the specified number of ports
|
||||
|
||||
Usage: ip_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 = "ip_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 IP demux {1}...".format(ports, name))
|
||||
|
||||
@ -441,7 +409,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -451,5 +419,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""ip_demux_64
|
||||
|
||||
"""
|
||||
Generates an IP demux with the specified number of ports
|
||||
|
||||
Usage: ip_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 = "ip_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 IP demux {1}...".format(ports, name))
|
||||
|
||||
@ -454,7 +422,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -464,5 +432,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""ip_mux
|
||||
|
||||
"""
|
||||
Generates an IP mux with the specified number of ports
|
||||
|
||||
Usage: ip_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 = "ip_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 IP mux {1}...".format(ports, name))
|
||||
|
||||
@ -491,7 +459,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -501,5 +469,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""ip_mux_64
|
||||
|
||||
"""
|
||||
Generates an IP mux with the specified number of ports
|
||||
|
||||
Usage: ip_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 = "ip_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 IP mux {1}...".format(ports, name))
|
||||
|
||||
@ -506,7 +474,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -516,5 +484,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,72 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""udp_arb_mux
|
||||
|
||||
"""
|
||||
Generates an arbitrated UDP mux with the specified number of ports
|
||||
|
||||
Usage: udp_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 = "udp_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))
|
||||
print("Generating {0} port UDP arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
select_width = int(math.ceil(math.log(ports, 2)))
|
||||
|
||||
@ -272,7 +240,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -282,5 +250,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,72 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""udp_arb_mux_64
|
||||
|
||||
"""
|
||||
Generates an arbitrated UDP mux with the specified number of ports
|
||||
|
||||
Usage: udp_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 = "udp_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))
|
||||
print("Generating {0} port UDP arbitrated mux {1}...".format(ports, name))
|
||||
|
||||
select_width = int(math.ceil(math.log(ports, 2)))
|
||||
|
||||
@ -276,7 +244,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -286,5 +254,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""udp_demux
|
||||
|
||||
Generates an UDP demux with the specified number of ports
|
||||
|
||||
Usage: udp_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
|
||||
"""
|
||||
Generates a UDP demux with the specified number of ports
|
||||
"""
|
||||
|
||||
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 = "udp_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 UDP demux {1}...".format(ports, name))
|
||||
|
||||
@ -473,7 +441,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -483,5 +451,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""udp_demux_64
|
||||
|
||||
Generates an UDP demux with the specified number of ports
|
||||
|
||||
Usage: udp_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
|
||||
"""
|
||||
Generates a UDP demux with the specified number of ports
|
||||
"""
|
||||
|
||||
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 = "udp_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 UDP demux {1}...".format(ports, name))
|
||||
|
||||
@ -486,7 +454,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -496,5 +464,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""udp_mux
|
||||
|
||||
Generates an UDP mux with the specified number of ports
|
||||
|
||||
Usage: udp_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
|
||||
"""
|
||||
Generates a UDP mux with the specified number of ports
|
||||
"""
|
||||
|
||||
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 = "udp_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 UDP mux {1}...".format(ports, name))
|
||||
|
||||
@ -531,7 +499,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -541,5 +509,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
@ -1,70 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""udp_mux_64
|
||||
|
||||
Generates an UDP mux with the specified number of ports
|
||||
|
||||
Usage: udp_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
|
||||
"""
|
||||
Generates a UDP mux with the specified number of ports
|
||||
"""
|
||||
|
||||
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 = "udp_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 UDP mux {1}...".format(ports, name))
|
||||
|
||||
@ -546,7 +514,7 @@ endmodule
|
||||
|
||||
""")
|
||||
|
||||
out_file.write(t.render(
|
||||
output_file.write(t.render(
|
||||
n=ports,
|
||||
w=select_width,
|
||||
name=name,
|
||||
@ -556,5 +524,5 @@ endmodule
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user