|
|
@ -1,4 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
from assembly import FETCH
|
|
|
|
from assembly import FETCH
|
|
|
|
import pin
|
|
|
|
import pin
|
|
|
|
|
|
|
|
|
|
|
@ -25,19 +24,29 @@ def save_hex_str(hex_str_lis, chunk_count: int):
|
|
|
|
for line in chunk(hex_str_lis, chunk_count):
|
|
|
|
for line in chunk(hex_str_lis, chunk_count):
|
|
|
|
print(line)
|
|
|
|
print(line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
data_width = 32
|
|
|
|
data_width = 32
|
|
|
|
addr_width = 16
|
|
|
|
addr_width = 16
|
|
|
|
|
|
|
|
|
|
|
|
# 我们现在只支持16个指令
|
|
|
|
# 我们现在只支持16个指令
|
|
|
|
code_hex_str = get_hex_str(FETCH, data_width / 4)
|
|
|
|
fetch_hex_str_lis = get_hex_str(FETCH, data_width / 4)
|
|
|
|
base_bin_data = get_hex_str([pin.HLT for _ in range(1 << addr_width)], data_width / 4)
|
|
|
|
base_bin_data = get_hex_str([pin.HLT for _ in range(1 << addr_width)], data_width / 4)
|
|
|
|
for addr in range(1 << addr_width):
|
|
|
|
for addr in range(1 << addr_width):
|
|
|
|
ir = addr >> 8
|
|
|
|
ir = addr >> 8
|
|
|
|
psw = (addr >> 4) & 0xf
|
|
|
|
psw = (addr >> 4) & 0xf
|
|
|
|
cyc = addr & 0xf
|
|
|
|
cyc = addr & 0xf # 最大支持2的4次方个指令
|
|
|
|
if cyc < len(code_hex_str):
|
|
|
|
|
|
|
|
base_bin_data[addr] = code_hex_str[cyc]
|
|
|
|
# 取指令周期
|
|
|
|
|
|
|
|
if cyc < len(fetch_hex_str_lis):
|
|
|
|
|
|
|
|
base_bin_data[addr] = fetch_hex_str_lis[cyc]
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 处理IR寄存器的值
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 写入数据到 bin文件
|
|
|
|
# 写入数据到 bin文件
|
|
|
|
addr_chunk = int(64 / (32 / 4)) # bin文件每行有多少个数据
|
|
|
|
addr_chunk = int(64 / (32 / 4)) # bin文件每行有多少个数据
|
|
|
|