aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/romload/map2debug.py
diff options
context:
space:
mode:
authorGuy Hutchison <guy@dryv.io>2018-10-18 18:47:06 +0000
committerGuy Hutchison <guy@dryv.io>2018-10-18 18:47:06 +0000
commitf47ac81c89a517a57fd3c0656cab7a4075334328 (patch)
treed61ff99f2271a3ef55245b1fda0c6556cdf34215 /scripts/romload/map2debug.py
parentef386e8f177519b86579b04a1b906f4cfaa09379 (diff)
downloadpicorv32-f47ac81c89a517a57fd3c0656cab7a4075334328.tar.gz
picorv32-f47ac81c89a517a57fd3c0656cab7a4075334328.zip
Passing with custom linker file
Diffstat (limited to 'scripts/romload/map2debug.py')
-rw-r--r--scripts/romload/map2debug.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/romload/map2debug.py b/scripts/romload/map2debug.py
new file mode 100644
index 0000000..a79af05
--- /dev/null
+++ b/scripts/romload/map2debug.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+import re
+
+symbol = re.compile("\s*0x([0-9a-f]+)\s+([\w_]+)\s*$")
+symbol_map = {}
+with open("firmware.map", "r") as fh:
+ for fd in fh:
+ sym = symbol.match(fd)
+ if (sym):
+ addr = int(sym.group(1), 16)
+ symbol_map[addr] = sym.group(2)
+
+with open("firmware_dbg.v", "w") as fh:
+ fh.write(" task firmware_dbg;\n")
+ fh.write(" input [31:0] addr;\n");
+ fh.write(" begin\n");
+ fh.write(" case (addr)\n");
+ for k, v in symbol_map.items():
+ fh.write(" 32'h{0:08x} : $display(\"%t: FCALL: {1:s}\", $time);\n".format(k, v))
+ fh.write(" endcase\n");
+ fh.write(" end\n");
+ fh.write(" endtask\n");
+
+with open("firmware_addr.txt", "w") as fh:
+ for k, v in symbol_map.items():
+ fh.write("{0:08x} {1:s}\n".format(k,v))
+