Commit 7549fa9e authored by Jonas Kaufmann's avatar Jonas Kaufmann Committed by Antoine Kaufmann
Browse files

pre-commit run -a

parent aac98df8
...@@ -21,20 +21,23 @@ ...@@ -21,20 +21,23 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import json import json
import re
import os import os
import re
def parse_nopaxos_run(num_c, seq, path): def parse_nopaxos_run(num_c, seq, path):
ret = {} ret = {}
ret['throughput'] = None ret['throughput'] = None
ret['latency'] = None ret['latency'] = None
tp_pat = re.compile(r'(.*)Completed *([0-9\.]*) requests in *([0-9\.]*) seconds') tp_pat = re.compile(
r'(.*)Completed *([0-9\.]*) requests in *([0-9\.]*) seconds'
)
lat_pat = re.compile(r'(.*)Average latency is *([0-9\.]*) ns(.*)') lat_pat = re.compile(r'(.*)Average latency is *([0-9\.]*) ns(.*)')
if not os.path.exists(path): if not os.path.exists(path):
return ret return ret
f_log = open(path, 'r') f_log = open(path, 'r')
log = json.load(f_log) log = json.load(f_log)
...@@ -43,27 +46,26 @@ def parse_nopaxos_run(num_c, seq, path): ...@@ -43,27 +46,26 @@ def parse_nopaxos_run(num_c, seq, path):
for i in range(num_c): for i in range(num_c):
sim_name = f'host.client.{i}' sim_name = f'host.client.{i}'
#print(sim_name) #print(sim_name)
# in this host log stdout # in this host log stdout
for j in log["sims"][sim_name]["stdout"]: for j in log['sims'][sim_name]['stdout']:
#print(j) #print(j)
m_t = tp_pat.match(j) m_t = tp_pat.match(j)
m_l = lat_pat.match(j) m_l = lat_pat.match(j)
if m_l: if m_l:
#print(j) #print(j)
lat = float(m_l.group(2)) / 1000 # us latency lat = float(m_l.group(2)) / 1000 # us latency
#print(lat) #print(lat)
total_avglat += lat total_avglat += lat
if m_t: if m_t:
n_req = float(m_t.group(2)) n_req = float(m_t.group(2))
n_time = float(m_t.group(3)) n_time = float(m_t.group(3))
total_tput += n_req/n_time total_tput += n_req / n_time
avglat = total_avglat/num_c avglat = total_avglat / num_c
#print(avglat) #print(avglat)
#print(total_tput) #print(total_tput)
ret['throughput'] = total_tput ret['throughput'] = total_tput
ret['latency'] = avglat ret['latency'] = avglat
......
...@@ -53,7 +53,7 @@ class l2_switch(): ...@@ -53,7 +53,7 @@ class l2_switch():
if table['type'] in table_types or len(table_types) == 0: if table['type'] in table_types or len(table_types) == 0:
try: try:
if verbose: if verbose:
print("Clearing table {:<40} ... ". print('Clearing table {:<40} ... '.
format(table['full_name']), format(table['full_name']),
end='', flush=True) end='', flush=True)
table['node'].clear(batch=batching) table['node'].clear(batch=batching)
...@@ -109,7 +109,7 @@ class l2_switch(): ...@@ -109,7 +109,7 @@ class l2_switch():
# no add() etc. Another reason is that the # no add() etc. Another reason is that the
# table is read-only. # table is read-only.
if verbose: if verbose:
print("Failed") print('Failed')
finally: finally:
if batching: if batching:
bfrt.batch_end() bfrt.batch_end()
...@@ -128,16 +128,16 @@ class l2_switch(): ...@@ -128,16 +128,16 @@ class l2_switch():
self.__init__() self.__init__()
# Enable learning on SMAC # Enable learning on SMAC
print("Initializing learning on SMAC ... ", end='', flush=True) print('Initializing learning on SMAC ... ', end='', flush=True)
try: try:
self.p4.IngressDeparser.l2_digest.callback_deregister() self.p4.IngressDeparser.l2_digest.callback_deregister()
except: except:
pass pass
self.p4.IngressDeparser.l2_digest.callback_register(self.learning_cb) self.p4.IngressDeparser.l2_digest.callback_register(self.learning_cb)
print("Done") print('Done')
# Enable aging on SMAC # Enable aging on SMAC
print("Inializing Aging on SMAC ... ", end='', flush=True) print('Inializing Aging on SMAC ... ', end='', flush=True)
try: try:
self.p4.Ingress.smac.idle_table_set_notify(enable=False, self.p4.Ingress.smac.idle_table_set_notify(enable=False,
callback=None) callback=None)
...@@ -149,7 +149,7 @@ class l2_switch(): ...@@ -149,7 +149,7 @@ class l2_switch():
# interval = 10000, # interval = 10000,
# min_ttl = 10000, # min_ttl = 10000,
# max_ttl = 60000) # max_ttl = 60000)
print("Done") print('Done')
@staticmethod @staticmethod
def aging_cb(dev_id, pipe_id, direction, parser_id, entry): def aging_cb(dev_id, pipe_id, direction, parser_id, entry):
...@@ -158,13 +158,13 @@ class l2_switch(): ...@@ -158,13 +158,13 @@ class l2_switch():
mac_addr = entry.key[b'hdr.ethernet.src_addr'] mac_addr = entry.key[b'hdr.ethernet.src_addr']
print("Aging out: MAC: {}".format(mac(mac_addr))) print('Aging out: MAC: {}'.format(mac(mac_addr)))
entry.remove() # from smac entry.remove() # from smac
try: try:
dmac.delete(dst_addr=mac_addr) dmac.delete(dst_addr=mac_addr)
except: except:
print("WARNING: Could not find the matching DMAC entry") print('WARNING: Could not find the matching DMAC entry')
@staticmethod @staticmethod
def learning_cb(dev_id, pipe_id, direction, parser_id, session, msg): def learning_cb(dev_id, pipe_id, direction, parser_id, session, msg):
...@@ -172,19 +172,19 @@ class l2_switch(): ...@@ -172,19 +172,19 @@ class l2_switch():
dmac = bfrt.nopaxos.pipe.Ingress.dmac dmac = bfrt.nopaxos.pipe.Ingress.dmac
for digest in msg: for digest in msg:
port = digest["ingress_port"] port = digest['ingress_port']
mac_move = digest["mac_move"] mac_move = digest['mac_move']
mac_addr = digest["src_mac"] mac_addr = digest['src_mac']
old_port = port ^ mac_move # Because mac_move = ingress_port ^ port old_port = port ^ mac_move # Because mac_move = ingress_port ^ port
print("MAC: {}, Port={}".format( print('MAC: {}, Port={}'.format(
mac(mac_addr), port), end="") mac(mac_addr), port), end='')
if mac_move != 0: if mac_move != 0:
print("(Move from port={})".format(old_port)) print('(Move from port={})'.format(old_port))
else: else:
print("(New)") print('(New)')
# Since we do not have access to self, we have to use # Since we do not have access to self, we have to use
# the hardcoded value for the TTL :( # the hardcoded value for the TTL :(
...@@ -221,7 +221,7 @@ def set_mcast(num_groups=1, num_sequencers=1): ...@@ -221,7 +221,7 @@ def set_mcast(num_groups=1, num_sequencers=1):
### Setup L2 learning ### Setup L2 learning
sl2 = l2_switch(default_ttl=10000) sl2 = l2_switch(default_ttl=10000)
sl2.setup() sl2.setup()
sl2.l2_add_smac_drop(1, "00:00:00:00:00:00") sl2.l2_add_smac_drop(1, '00:00:00:00:00:00')
bfrt.complete_operations() bfrt.complete_operations()
p4 = bfrt.nopaxos.pipe p4 = bfrt.nopaxos.pipe
...@@ -236,5 +236,5 @@ bfrt.complete_operations() ...@@ -236,5 +236,5 @@ bfrt.complete_operations()
### Register print out ### Register print out
print("""******************* SETUP RESULTS *****************""") print("""******************* SETUP RESULTS *****************""")
print ("\n reg_cnt:") print ('\n reg_cnt:')
p4.Ingress.reg_cnt.get(REGISTER_INDEX=0, from_hw=True) p4.Ingress.reg_cnt.get(REGISTER_INDEX=0, from_hw=True)
...@@ -54,7 +54,7 @@ class l2_switch(): ...@@ -54,7 +54,7 @@ class l2_switch():
if table['type'] in table_types or len(table_types) == 0: if table['type'] in table_types or len(table_types) == 0:
try: try:
if verbose: if verbose:
print("Clearing table {:<40} ... ". print('Clearing table {:<40} ... '.
format(table['full_name']), format(table['full_name']),
end='', flush=True) end='', flush=True)
table['node'].clear(batch=batching) table['node'].clear(batch=batching)
...@@ -110,7 +110,7 @@ class l2_switch(): ...@@ -110,7 +110,7 @@ class l2_switch():
# no add() etc. Another reason is that the # no add() etc. Another reason is that the
# table is read-only. # table is read-only.
if verbose: if verbose:
print("Failed") print('Failed')
finally: finally:
if batching: if batching:
bfrt.batch_end() bfrt.batch_end()
...@@ -151,16 +151,16 @@ class l2_switch(): ...@@ -151,16 +151,16 @@ class l2_switch():
self.p4.Egress.port_vlan_tagged.symmetric_mode_set(False) self.p4.Egress.port_vlan_tagged.symmetric_mode_set(False)
# Enable learning on SMAC # Enable learning on SMAC
print("Initializing learning on SMAC ... ", end='', flush=True) print('Initializing learning on SMAC ... ', end='', flush=True)
try: try:
self.p4.IngressDeparser.l2_digest.callback_deregister() self.p4.IngressDeparser.l2_digest.callback_deregister()
except: except:
pass pass
self.p4.IngressDeparser.l2_digest.callback_register(self.learning_cb) self.p4.IngressDeparser.l2_digest.callback_register(self.learning_cb)
print("Done") print('Done')
# Enable aging on SMAC # Enable aging on SMAC
print("Inializing Aging on SMAC ... ", end='', flush=True) print('Inializing Aging on SMAC ... ', end='', flush=True)
self.p4.Ingress.smac.idle_table_set_notify(enable=False, self.p4.Ingress.smac.idle_table_set_notify(enable=False,
callback=None) callback=None)
...@@ -169,7 +169,7 @@ class l2_switch(): ...@@ -169,7 +169,7 @@ class l2_switch():
interval = 10000, interval = 10000,
min_ttl = 10000, min_ttl = 10000,
max_ttl = 60000) max_ttl = 60000)
print("Done") print('Done')
@staticmethod @staticmethod
def aging_cb(dev_id, pipe_id, direction, parser_id, entry): def aging_cb(dev_id, pipe_id, direction, parser_id, entry):
...@@ -179,13 +179,13 @@ class l2_switch(): ...@@ -179,13 +179,13 @@ class l2_switch():
vid = entry.key[b'meta.vid'] vid = entry.key[b'meta.vid']
mac_addr = entry.key[b'hdr.ethernet.src_addr'] mac_addr = entry.key[b'hdr.ethernet.src_addr']
print("Aging out: VID: {}, MAC: {}".format(vid, mac(mac_addr))) print('Aging out: VID: {}, MAC: {}'.format(vid, mac(mac_addr)))
entry.remove() # from smac entry.remove() # from smac
try: try:
dmac.delete(vid=vid, dst_addr=mac_addr) dmac.delete(vid=vid, dst_addr=mac_addr)
except: except:
print("WARNING: Could not find the matching DMAC entry") print('WARNING: Could not find the matching DMAC entry')
@staticmethod @staticmethod
def learning_cb(dev_id, pipe_id, direction, parser_id, session, msg): def learning_cb(dev_id, pipe_id, direction, parser_id, session, msg):
...@@ -193,20 +193,20 @@ class l2_switch(): ...@@ -193,20 +193,20 @@ class l2_switch():
dmac = bfrt.l2_switch.pipe.Ingress.dmac dmac = bfrt.l2_switch.pipe.Ingress.dmac
for digest in msg: for digest in msg:
vid = digest["vid"] vid = digest['vid']
port = digest["ingress_port"] port = digest['ingress_port']
mac_move = digest["mac_move"] mac_move = digest['mac_move']
mac_addr = digest["src_mac"] mac_addr = digest['src_mac']
old_port = port ^ mac_move # Because mac_move = ingress_port ^ port old_port = port ^ mac_move # Because mac_move = ingress_port ^ port
print("VID: {}, MAC: {}, Port={}".format( print('VID: {}, MAC: {}, Port={}'.format(
vid, mac(mac_addr), port), end="") vid, mac(mac_addr), port), end='')
if mac_move != 0: if mac_move != 0:
print("(Move from port={})".format(old_port)) print('(Move from port={})'.format(old_port))
else: else:
print("(New)") print('(New)')
# Since we do not have access to self, we have to use # Since we do not have access to self, we have to use
# the hardcoded value for the TTL :( # the hardcoded value for the TTL :(
...@@ -220,9 +220,9 @@ class l2_switch(): ...@@ -220,9 +220,9 @@ class l2_switch():
def vlan_create(self, vid): def vlan_create(self, vid):
if vid in self.vlan: if vid in self.vlan:
raise KeyError("Vlan {} already exists".format(vid)) raise KeyError('Vlan {} already exists'.format(vid))
if not 1 <= vid <= 4095: if not 1 <= vid <= 4095:
raise ValueError("Vlan ID {} is incorrect".format(vid)) raise ValueError('Vlan ID {} is incorrect'.format(vid))
bfrt.pre.node.entry(MULTICAST_NODE_ID = vid, bfrt.pre.node.entry(MULTICAST_NODE_ID = vid,
MULTICAST_RID = 0xFFFF, # See P4 code MULTICAST_RID = 0xFFFF, # See P4 code
...@@ -233,7 +233,7 @@ class l2_switch(): ...@@ -233,7 +233,7 @@ class l2_switch():
MULTICAST_NODE_L1_XID_VALID = [0], MULTICAST_NODE_L1_XID_VALID = [0],
MULTICAST_NODE_L1_XID = [0]).push() MULTICAST_NODE_L1_XID = [0]).push()
self.vlan[vid] = { self.vlan[vid] = {
"ports": {} 'ports': {}
} }
...@@ -284,15 +284,15 @@ class l2_switch(): ...@@ -284,15 +284,15 @@ class l2_switch():
for vid in sorted(vlans): for vid in sorted(vlans):
print ('| {:>4d} | '.format(vid), end='') print ('| {:>4d} | '.format(vid), end='')
for p in sorted(self.vlan[vid]["ports"].keys()): for p in sorted(self.vlan[vid]['ports'].keys()):
print(p, end='') print(p, end='')
if self.vlan[vid]["ports"][p]: if self.vlan[vid]['ports'][p]:
print("(T)", end='') print('(T)', end='')
else: else:
print("(U)", end='') print('(U)', end='')
print() print()
print( "+------+------------------------------------------") print( '+------+------------------------------------------')
def vlan_port_add(self, vid, dp, tagged=False): def vlan_port_add(self, vid, dp, tagged=False):
if vid not in self.vlan: if vid not in self.vlan:
...@@ -340,7 +340,7 @@ class l2_switch(): ...@@ -340,7 +340,7 @@ class l2_switch():
vid << 7 | port, 0, pipe=pipe) vid << 7 | port, 0, pipe=pipe)
# Update internal state # Update internal state
vlan_ports = self.vlan[vid]["ports"] vlan_ports = self.vlan[vid]['ports']
vlan_ports[dp] = tagged vlan_ports[dp] = tagged
def vlan_port_delete(self, vid, dp): def vlan_port_delete(self, vid, dp):
...@@ -397,7 +397,7 @@ class l2_switch(): ...@@ -397,7 +397,7 @@ class l2_switch():
try: try:
default_vid = self.port_vlan_default_get(dp) default_vid = self.port_vlan_default_get(dp)
if default_vid != 0 or show_all: if default_vid != 0 or show_all:
print("Port %3d : Default VLAN is %4d" % (dp, default_vid)) print('Port %3d : Default VLAN is %4d' % (dp, default_vid))
except: except:
pass pass
...@@ -427,54 +427,54 @@ class l2_switch(): ...@@ -427,54 +427,54 @@ class l2_switch():
def l2_print(self, dmac_entry, smac_entry): def l2_print(self, dmac_entry, smac_entry):
vid = None vid = None
mac_addr = None mac_addr = None
port = " " port = ' '
pending = " " pending = ' '
valid = " " valid = ' '
static = " " static = ' '
dst_drop = " " dst_drop = ' '
src_drop = " " src_drop = ' '
static = " " static = ' '
ttl = " " ttl = ' '
dmac_eh_s= " " dmac_eh_s= ' '
smac_eh_s= " " smac_eh_s= ' '
if dmac_entry is not None: if dmac_entry is not None:
valid = "Y" valid = 'Y'
vid = dmac_entry.key[b'meta.vid'] vid = dmac_entry.key[b'meta.vid']
mac_addr = mac(dmac_entry.key[b'hdr.ethernet.dst_addr']) mac_addr = mac(dmac_entry.key[b'hdr.ethernet.dst_addr'])
if dmac_entry.action.endswith("dmac_drop"): if dmac_entry.action.endswith('dmac_drop'):
dst_drop = "Y" dst_drop = 'Y'
else: else:
dst_drop = " " dst_drop = ' '
if dmac_entry.action.endswith("dmac_unicast"): if dmac_entry.action.endswith('dmac_unicast'):
port = dmac_entry.data[b'port'] port = dmac_entry.data[b'port']
if smac_entry is not None: if smac_entry is not None:
valid = "Y" valid = 'Y'
ttl = int(smac_entry.data[b'$ENTRY_TTL']) ttl = int(smac_entry.data[b'$ENTRY_TTL'])
if ttl > 1000 or ttl == 0: if ttl > 1000 or ttl == 0:
ttl = "%6d" % (ttl/1000) ttl = '%6d' % (ttl/1000)
else: else:
ttl = " 0.%03d" % ttl ttl = ' 0.%03d' % ttl
if dmac_entry is None: if dmac_entry is None:
vid = smac_entry.key[b'meta.vid'] vid = smac_entry.key[b'meta.vid']
mac_addr = mac(smac_entry.key[b'hdr.ethernet.src_addr']) mac_addr = mac(smac_entry.key[b'hdr.ethernet.src_addr'])
if smac_entry.action.endswith("smac_hit"): if smac_entry.action.endswith('smac_hit'):
if (dmac_entry is None or if (dmac_entry is None or
dmac_entry.action.endswith("dmac_miss")): dmac_entry.action.endswith('dmac_miss')):
pending = "Y" pending = 'Y'
port = smac_entry.data[b'port'] port = smac_entry.data[b'port']
if smac_entry.data[b'is_static']: if smac_entry.data[b'is_static']:
static = "Y" static = 'Y'
elif smac_entry.action.endswith("smac_drop"): elif smac_entry.action.endswith('smac_drop'):
src_drop = "Y" src_drop = 'Y'
if dmac_entry or smac_entry: if dmac_entry or smac_entry:
print("| %4d | %s | %3d | %s %s %s | %s %s | %s |" % ( print('| %4d | %s | %3d | %s %s %s | %s %s | %s |' % (
vid, mac_addr, port, vid, mac_addr, port,
valid, pending, static, valid, pending, static,
src_drop, dst_drop, src_drop, dst_drop,
...@@ -537,7 +537,7 @@ sl2.port_vlan_default_set(0, 1) ...@@ -537,7 +537,7 @@ sl2.port_vlan_default_set(0, 1)
sl2.port_vlan_default_set(1, 1) sl2.port_vlan_default_set(1, 1)
sl2.port_vlan_default_set(2, 1) sl2.port_vlan_default_set(2, 1)
sl2.port_vlan_default_set(3, 1) sl2.port_vlan_default_set(3, 1)
sl2.l2_add_smac_drop(1, "00:00:00:00:00:00") sl2.l2_add_smac_drop(1, '00:00:00:00:00:00')
bfrt.complete_operations() bfrt.complete_operations()
sl2.vlan_show() sl2.vlan_show()
......
#!/usr/bin/env python #!/usr/bin/env python
""" """Generates an AXI Stream arbitrated mux wrapper with the specified number of
Generates an AXI Stream arbitrated mux wrapper with the specified number of ports ports."""
"""
from __future__ import print_function from __future__ import print_function
...@@ -11,9 +10,9 @@ from jinja2 import Template ...@@ -11,9 +10,9 @@ from jinja2 import Template
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__.strip()) parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports") 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('-n', '--name', type=str, help='module name')
parser.add_argument('-o', '--output', type=str, help="output file name") parser.add_argument('-o', '--output', type=str, help='output file name')
args = parser.parse_args() args = parser.parse_args()
...@@ -27,16 +26,16 @@ def generate(ports=4, name=None, output=None): ...@@ -27,16 +26,16 @@ def generate(ports=4, name=None, output=None):
n = ports n = ports
if name is None: if name is None:
name = "axis_arb_mux_wrap_{0}".format(n) name = 'axis_arb_mux_wrap_{0}'.format(n)
if output is None: if output is None:
output = name + ".v" output = name + '.v'
print("Opening file '{0}'...".format(output)) print("Opening file '{0}'...".format(output))
output_file = open(output, 'w') output_file = open(output, 'w')
print("Generating {0} port AXI stream arbitrated mux wrapper {1}...".format(n, name)) print('Generating {0} port AXI stream arbitrated mux wrapper {1}...'.format(n, name))
cn = int(math.ceil(math.log(n, 2))) cn = int(math.ceil(math.log(n, 2)))
...@@ -173,8 +172,7 @@ endmodule ...@@ -173,8 +172,7 @@ endmodule
name=name name=name
)) ))
print("Done") print('Done')
if __name__ == "__main__": if __name__ == '__main__':
main() main()
#!/usr/bin/env python #!/usr/bin/env python
""" """Generates an AXI Stream crosspoint wrapper with the specified number of
Generates an AXI Stream crosspoint wrapper with the specified number of ports ports."""
"""
from __future__ import print_function from __future__ import print_function
...@@ -11,9 +10,9 @@ from jinja2 import Template ...@@ -11,9 +10,9 @@ from jinja2 import Template
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__.strip()) parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=[4], nargs='+', help="number of ports") parser.add_argument('-p', '--ports', type=int, default=[4], nargs='+', help='number of ports')
parser.add_argument('-n', '--name', type=str, help="module name") parser.add_argument('-n', '--name', type=str, help='module name')
parser.add_argument('-o', '--output', type=str, help="output file name") parser.add_argument('-o', '--output', type=str, help='output file name')
args = parser.parse_args() args = parser.parse_args()
...@@ -32,16 +31,16 @@ def generate(ports=4, name=None, output=None): ...@@ -32,16 +31,16 @@ def generate(ports=4, name=None, output=None):
m, n = ports m, n = ports
if name is None: if name is None:
name = "axis_crosspoint_wrap_{0}x{1}".format(m, n) name = 'axis_crosspoint_wrap_{0}x{1}'.format(m, n)
if output is None: if output is None:
output = name + ".v" output = name + '.v'
print("Opening file '{0}'...".format(output)) print("Opening file '{0}'...".format(output))
output_file = open(output, 'w') output_file = open(output, 'w')
print("Generating {0}x{1} port AXI stream crosspoint wrapper {2}...".format(m, n, name)) print('Generating {0}x{1} port AXI stream crosspoint wrapper {2}...'.format(m, n, name))
cm = int(math.ceil(math.log(m, 2))) cm = int(math.ceil(math.log(m, 2)))
cn = int(math.ceil(math.log(n, 2))) cn = int(math.ceil(math.log(n, 2)))
...@@ -185,8 +184,7 @@ endmodule ...@@ -185,8 +184,7 @@ endmodule
name=name name=name
)) ))
print("Done") print('Done')
if __name__ == "__main__": if __name__ == '__main__':
main() main()
#!/usr/bin/env python #!/usr/bin/env python
""" """Generates an AXI Stream demux wrapper with the specified number of ports."""
Generates an AXI Stream demux wrapper with the specified number of ports
"""
from __future__ import print_function from __future__ import print_function
...@@ -11,9 +9,9 @@ from jinja2 import Template ...@@ -11,9 +9,9 @@ from jinja2 import Template
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__.strip()) parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports") 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('-n', '--name', type=str, help='module name')
parser.add_argument('-o', '--output', type=str, help="output file name") parser.add_argument('-o', '--output', type=str, help='output file name')
args = parser.parse_args() args = parser.parse_args()
...@@ -27,16 +25,16 @@ def generate(ports=4, name=None, output=None): ...@@ -27,16 +25,16 @@ def generate(ports=4, name=None, output=None):
n = ports n = ports
if name is None: if name is None:
name = "axis_demux_wrap_{0}".format(n) name = 'axis_demux_wrap_{0}'.format(n)
if output is None: if output is None:
output = name + ".v" output = name + '.v'
print("Opening file '{0}'...".format(output)) print("Opening file '{0}'...".format(output))
output_file = open(output, 'w') output_file = open(output, 'w')
print("Generating {0} port AXI stream demux wrapper {1}...".format(n, name)) print('Generating {0} port AXI stream demux wrapper {1}...'.format(n, name))
cn = int(math.ceil(math.log(n, 2))) cn = int(math.ceil(math.log(n, 2)))
...@@ -179,8 +177,7 @@ endmodule ...@@ -179,8 +177,7 @@ endmodule
name=name name=name
)) ))
print("Done") print('Done')
if __name__ == "__main__": if __name__ == '__main__':
main() main()
#!/usr/bin/env python #!/usr/bin/env python
""" """Generates an AXI Stream frame joiner wrapper with the specified number of
Generates an AXI Stream frame joiner wrapper with the specified number of ports ports."""
"""
from __future__ import print_function from __future__ import print_function
...@@ -11,9 +10,9 @@ from jinja2 import Template ...@@ -11,9 +10,9 @@ from jinja2 import Template
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__.strip()) parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports") 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('-n', '--name', type=str, help='module name')
parser.add_argument('-o', '--output', type=str, help="output file name") parser.add_argument('-o', '--output', type=str, help='output file name')
args = parser.parse_args() args = parser.parse_args()
...@@ -27,16 +26,16 @@ def generate(ports=4, name=None, output=None): ...@@ -27,16 +26,16 @@ def generate(ports=4, name=None, output=None):
n = ports n = ports
if name is None: if name is None:
name = "axis_frame_join_wrap_{0}".format(n) name = 'axis_frame_join_wrap_{0}'.format(n)
if output is None: if output is None:
output = name + ".v" output = name + '.v'
print("Opening file '{0}'...".format(output)) print("Opening file '{0}'...".format(output))
output_file = open(output, 'w') output_file = open(output, 'w')
print("Generating {0} port AXI stream frame joiner wrapper {1}...".format(n, name)) print('Generating {0} port AXI stream frame joiner wrapper {1}...'.format(n, name))
cn = int(math.ceil(math.log(n, 2))) cn = int(math.ceil(math.log(n, 2)))
...@@ -151,8 +150,7 @@ endmodule ...@@ -151,8 +150,7 @@ endmodule
name=name name=name
)) ))
print("Done") print('Done')
if __name__ == "__main__": if __name__ == '__main__':
main() main()
#!/usr/bin/env python #!/usr/bin/env python
""" """Generates an AXI Stream mux wrapper with the specified number of ports."""
Generates an AXI Stream mux wrapper with the specified number of ports
"""
from __future__ import print_function from __future__ import print_function
...@@ -11,9 +9,9 @@ from jinja2 import Template ...@@ -11,9 +9,9 @@ from jinja2 import Template
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__.strip()) parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=4, help="number of ports") 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('-n', '--name', type=str, help='module name')
parser.add_argument('-o', '--output', type=str, help="output file name") parser.add_argument('-o', '--output', type=str, help='output file name')
args = parser.parse_args() args = parser.parse_args()
...@@ -27,16 +25,16 @@ def generate(ports=4, name=None, output=None): ...@@ -27,16 +25,16 @@ def generate(ports=4, name=None, output=None):
n = ports n = ports
if name is None: if name is None:
name = "axis_mux_wrap_{0}".format(n) name = 'axis_mux_wrap_{0}'.format(n)
if output is None: if output is None:
output = name + ".v" output = name + '.v'
print("Opening file '{0}'...".format(output)) print("Opening file '{0}'...".format(output))
output_file = open(output, 'w') output_file = open(output, 'w')
print("Generating {0} port AXI stream mux wrapper {1}...".format(n, name)) print('Generating {0} port AXI stream mux wrapper {1}...'.format(n, name))
cn = int(math.ceil(math.log(n, 2))) cn = int(math.ceil(math.log(n, 2)))
...@@ -176,8 +174,7 @@ endmodule ...@@ -176,8 +174,7 @@ endmodule
name=name name=name
)) ))
print("Done") print('Done')
if __name__ == "__main__": if __name__ == '__main__':
main() main()
#!/usr/bin/env python #!/usr/bin/env python
""" """Generates an AXI Stream switch wrapper with the specified number of ports."""
Generates an AXI Stream switch wrapper with the specified number of ports
"""
from __future__ import print_function from __future__ import print_function
...@@ -11,9 +9,9 @@ from jinja2 import Template ...@@ -11,9 +9,9 @@ from jinja2 import Template
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__.strip()) parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=[4], nargs='+', help="number of ports") parser.add_argument('-p', '--ports', type=int, default=[4], nargs='+', help='number of ports')
parser.add_argument('-n', '--name', type=str, help="module name") parser.add_argument('-n', '--name', type=str, help='module name')
parser.add_argument('-o', '--output', type=str, help="output file name") parser.add_argument('-o', '--output', type=str, help='output file name')
args = parser.parse_args() args = parser.parse_args()
...@@ -32,16 +30,16 @@ def generate(ports=4, name=None, output=None): ...@@ -32,16 +30,16 @@ def generate(ports=4, name=None, output=None):
m, n = ports m, n = ports
if name is None: if name is None:
name = "axis_switch_wrap_{0}x{1}".format(m, n) name = 'axis_switch_wrap_{0}x{1}'.format(m, n)
if output is None: if output is None:
output = name + ".v" output = name + '.v'
print("Opening file '{0}'...".format(output)) print("Opening file '{0}'...".format(output))
output_file = open(output, 'w') output_file = open(output, 'w')
print("Generating {0}x{1} port AXI stream switch wrapper {2}...".format(m, n, name)) print('Generating {0}x{1} port AXI stream switch wrapper {2}...'.format(m, n, name))
cm = int(math.ceil(math.log(m, 2))) cm = int(math.ceil(math.log(m, 2)))
cn = int(math.ceil(math.log(n, 2))) cn = int(math.ceil(math.log(n, 2)))
...@@ -212,8 +210,7 @@ endmodule ...@@ -212,8 +210,7 @@ endmodule
name=name name=name
)) ))
print("Done") print('Done')
if __name__ == "__main__": if __name__ == '__main__':
main() main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment