Modify data store location

This commit is contained in:
unlockable
2024-07-13 14:21:03 +08:00
parent de2e42bef3
commit 835e7b2b5f
5 changed files with 802 additions and 1 deletions

View File

@@ -1,10 +1,35 @@
import random
total_count = random.randint(5, 50)
total_count = 20
numbers = list()
for _ in range(20):
for _ in range(total_count):
numbers.append(random.randint(0, 65535))
numbers = [
0x4B8D,
0x2307,
0xFAE0,
0x7815,
0xC105,
0x84F0,
0xDB6,
0xF21D,
0xE97A,
0xA3B6,
0x8466,
0x3A25,
0x5DF,
0xD2DE,
0xBA7A,
0x7809,
0xF6A8,
0x361D,
0x3ADB,
0x969A,
]
with open("gen_num.txt", "w") as fl:
fl.writelines([hex(x) + "\n" for x in numbers])
@@ -12,5 +37,24 @@ with open("gen_num_asm.txt", "w") as fl:
for idx, num in enumerate(numbers):
fl.write("addi $s1, $zero, %s\nsw $s1, %d($s0)\n" % (hex(num), 4 * idx))
with open("gen_num_data_mem.txt", "w") as fl:
fl.write(
"""for (i = StartAddressInWord; i < 24 + StartAddressInWord; i = i + 1) begin
memory_data[i] <= 32'h00000000;
end
for (
i = %d + StartAddressInWord; i < MEM_SIZE_IN_WORD + StartAddressInWord; i = i + 1
) begin
memory_data[i] <= 32'h00000000;
end
"""
% (24 + total_count + 1)
)
fl.write("memory_data[StartAddressInWord + 24] <= 32'h%08X;\n" % total_count)
for idx, num in enumerate(numbers):
fl.write(
"memory_data[StartAddressInWord + %d] <= 32'h%08X;\n" % (idx + 25, num)
)
with open("gen_num_sorted.txt", "w") as fl:
fl.writelines([hex(x) + "\n" for x in sorted(numbers)])