Issue
Trying to print out large traces of memory addresses (32 bits) for 2^32 addresses in the following manner:
0x12345678 W
0x23456789 R
.
.
.
.
0xFFFFFFFF W
Basically going from one address to the other. So it could be going from 0x0000000 to 0x00000003, we would have 0x0000000 R, 0x0000001 R, 0x0000002 R, 0x0000003 W.
Main goal is to feed them to a simulator but I am having storage and memory issues printing these (using print()) and storing them in a file in Python. I can't compress them because the simulator takes them in the above fashion. What is a good, efficient way to print them and store them in Python?
Solution
I would start by using just a file (for larger results) as print()
is kind of slow. Maybe:
start = 0
end = 4
w_or_r = ["R", "W"]
with open("results.txt", "w") as file_out:
for i in range(start, end):
file_out.write(f"0x{i:08x} {w_or_r[i % 2]}\n")
That should give you a file like:
0x00000000 R
0x00000001 W
0x00000002 R
0x00000003 W
Answered By - JonSG
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.