with open("adding.bin", "rb") as f: content = f.read() length_bits = len(content) * 8 mash = "".join([hex(int(i))[2:].zfill(2) for i in content]) shadow = f"reg [0:{length_bits-1}] mem = {length_bits}'h{mash}; // generated" print(shadow)