-
Notifications
You must be signed in to change notification settings - Fork 7
/
avail_mem.py
40 lines (36 loc) · 1.41 KB
/
avail_mem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!python3
import glob
dirs = glob.glob("build/F3DEX3_*")
if len(dirs) == 0:
raise RuntimeError("Please build one or more microcode versions in build/ first")
smallestDmemAvail = 1000000
smallestImemAvail = 1000000
for dir in dirs:
toks = dir.split("/")
assert len(toks) == 2
ucodename = toks[1]
dmemAvail = None
imemAvail = None
with open(dir + "/" + ucodename + ".sym", "r") as f:
for l in f:
toks = l.strip().split(" ")
if len(toks) != 2:
continue
addr = int(toks[0], 16)
sym = toks[1]
if sym == "startFreeDmem":
dmemAvail = addr
elif sym == "endFreeDmem":
dmemAvail = addr - dmemAvail
elif sym == "startFreeImem":
imemAvail = addr
elif sym == "endFreeImem":
imemAvail = addr - imemAvail
if dmemAvail == None or imemAvail == None:
raise RuntimeError("Failed to extract addresses from sym file for " + ucodename)
print(f"{ucodename:<22}: DMEM avail: {dmemAvail:2d} bytes | IMEM avail: {imemAvail//4:2d} instr")
if dmemAvail < smallestDmemAvail:
smallestDmemAvail = dmemAvail
if imemAvail < smallestImemAvail:
smallestImemAvail = imemAvail
print(f"Minimum : DMEM avail: {smallestDmemAvail:2d} bytes | IMEM avail: {smallestImemAvail//4:2d} instr")