增加测试代码,让整个主站的代码工作在RV32E的编译选项下,仅中断代码工作在RV32I的编译选项下,可以优化中断的速度。代码仅做备份,中断部分执行不正常

This commit is contained in:
2025-02-03 07:51:54 +08:00
parent 1ae3a395d8
commit ab506a0e37
5 changed files with 219 additions and 56 deletions

45
tb/sw/bin_2_c_array.py Normal file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/python3
def bin_2_c_array_file(bin_file, c_file):
# 打开二进制文件和输出的 C 文件
with open(bin_file, 'rb') as bf, open(c_file, 'w') as cf:
# 写入文件头
cf.write('#include "stdint.h"\n')
#cf.write('const uint8_t mst_svr_code[] __attribute__((aligned(32), section(".trap_entry"))) = {\n')
cf.write('const uint8_t mst_svr_code[] __attribute__((aligned(32))) = {\n')
all_data = bf.read()
# 将二进制内容按每4字节分割并转换为十六进制字符串
for i in range(len(all_data)):
cf.write('0x%02x, ' % all_data[i])
if ((i + 1) % 16) == 0:
cf.write('\n')
if ((len(all_data) + 1) % 16) != 0:
cf.write('\n};\n')
else:
cf.write('};\n')
'''
wstr = ''
for i in range(len(all_data)):
wstr = wstr + '0x%02x, ' % all_data[i]
if ((i + 1) % 16) == 0:
cf.write(wstr + '\n')
wstr = ''
if len(wstr) != 0:
cf.write(wstr)
cf.write('\n};\n')
'''
cf.close()
bf.close()
if __name__ == '__main__':
import sys
#import os
#print(len(sys.argv), sys.argv, os.getcwd())
# 运行脚本
#bin_to_coe_file("./tb/sw/build/slvTest.bin", "./tb/sw/build/slvTest.coe")
if len(sys.argv) >= 3:
bin_2_c_array_file(sys.argv[1], sys.argv[2])