RISCV/ripestohex.py

31 lines
993 B
Python

if __name__ == "__main__":
ripes: str = """
00000000 <START>:
0: 00100093 00000000000100000000000010010011
4: 00000133 00000000000000000000000100110011
8: 000001b3 00000000000000000000000110110011
c: 7ff00213 01111111111100000000001000010011
10: 00521213 00000000010100100001001000010011
00000014 <REG2UP>:
14: 00110133 00000000000100010000000100110011
18: 000001b3 00000000000000000000000110110011
0000001c <REG3UP>:
1c: 001181b3 00000000000100011000000110110011
20: fe41fae3 11111110010000011111101011100011
24: ff9ff0ef 11111111100111111111000011101111
"""
raw = ripes.split(" ")
cmd: list = []
for i in raw:
if len(i) == 8:
cmd.append(i)
final: str = ""
for i in cmd:
final += f"x\"{i}\", "
final += "others => (others => '0')"
print(final)