1 Star 0 Fork 1

chla/RISCV-CPU_2_isdowning

forked from cccccc9/RISCV-CPU 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
binary_to_hex.py 1000 Bytes
一键复制 编辑 原始数据 按行查看 历史
#! /usr/bin/env python3
from __future__ import print_function
import sys
import os
import subprocess
def main(args):
file = open(args[1])
lines = [l for l in file.readlines()]
def mapper(strr):
try:
return hex(int(strr, 2))[2:]
except Exception:
return 'x'
results = []
for l in lines:
hexes = list(map(mapper,l.split()))
ra = ''.join(hexes[:8])
sp = ''.join(hexes[8:16])
t0 = ''.join(hexes[16:24])
t1 = ''.join(hexes[24:32])
t2 = ''.join(hexes[32:40])
s0 = ''.join(hexes[40:48])
s1 = ''.join(hexes[48:56])
a0 = ''.join(hexes[56:64])
fetchAddr = ''.join(hexes[64:72])
inst = ''.join(hexes[72:80])
time_step = ''.join(hexes[80:84])
result = ["ra: ", ra, "sp: ", sp, "t0: ", t0, "t1: ", t1, "t2: ", t2, "s0: ", s0, "s1: ", s1, "a0: ", a0,
"PC: ", fetchAddr, "inst: ", inst, "Time_Step: ", time_step]
results.append(result)
for i in range(len(results)):
string2 = ' '.join(results[i])
print(string2)
if __name__ == "__main__":
main(sys.argv)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chla/RISCV-CPU_2_isdowning.git
git@gitee.com:chla/RISCV-CPU_2_isdowning.git
chla
RISCV-CPU_2_isdowning
RISCV-CPU_2_isdowning
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385