<filename>tests/cod19grp5/Uncommented/thinpad_top.srcs/sources_1/new/genmem.py<gh_stars>0
import os,sys
import binascii
routing_term=[
    "172.16.58.3/4",
    "172.16.17.32/4",
    "10.0.0.3/4",
    "10.0.0.4/4",
    "172.16.17.32/4",
    "172.16.17.32/4",
    "192.168.127.12/4",
    "192.168.3.11/4",
    "172.16.17.32/4",
    "172.16.17.32/4",
    "192.168.3.11/4",
    "172.16.17.32/4",
    "192.0.0.0/4",
    "192.168.127.12/4",
    "172.16.17.32/4",
    "240.0.0.0/4"
]
with open("tmp.mem","w") as f:
    #f.write("; This .COE file specifies the contents for a block memory of depth=16384, and width=14.\n")
    #f.write("memory_initialization_radix=2;\n")
    #f.write("memory_initialization_vector=\n")
    num = 0
    for item in routing_term:
        mask = int(item.split("/")[1])
        ip = "".join(['{:08b}'.format(int(x)) for x in item.split("/")[0].split(".")])
        s = "00"+"0"*14+"00100"+"01"+ip+"0"
        s_16 = '{:014x}'.format(int(s,2))
        f.write("@"+'{:04x}'.format(num)+" "+s_16+" ")
        num = num+1
    while(num<16384):
        f.write("@"+'{:04x}'.format(num)+" "+"0"*14+" ")
        num=num+1


<filename>tests/cod19grp5/Uncommented/thinpad_top.srcs/sources_1/new/genmem.py<gh_stars>0
import os,sys
import binascii
routing_term=[
    "172.16.58.3/4",
    "172.16.17.32/4",
    "10.0.0.3/4",
    "10.0.0.4/4",
    "172.16.17.32/4",
    "172.16.17.32/4",
    "192.168.127.12/4",
    "192.168.3.11/4",
    "172.16.17.32/4",
    "172.16.17.32/4",
    "192.168.3.11/4",
    "172.16.17.32/4",
    "192.0.0.0/4",
    "192.168.127.12/4",
    "172.16.17.32/4",
    "240.0.0.0/4"
]
with open("tmp.mem","w") as f:
    #f.write("; This .COE file specifies the contents for a block memory of depth=16384, and width=14.\n")
    #f.write("memory_initialization_radix=2;\n")
    #f.write("memory_initialization_vector=\n")
    num = 0
    for item in routing_term:
        mask = int(item.split("/")[1])
        ip = "".join(['{:08b}'.format(int(x)) for x in item.split("/")[0].split(".")])
        s = "00"+"0"*14+"00100"+"01"+ip+"0"
        s_16 = '{:014x}'.format(int(s,2))
        f.write("@"+'{:04x}'.format(num)+" "+s_16+" ")
        num = num+1
    while(num<16384):
        f.write("@"+'{:04x}'.format(num)+" "+"0"*14+" ")
        num=num+1


#f.write("; This .COE file specifies the contents for a block memory of depth=16384, and width=14.\n") #f.write("memory_initialization_radix=2;\n") #f.write("memory_initialization_vector=\n")