tools: dthex2vhdl added. read source for readme
authorBernhard Urban <lewurm@gmail.com>
Sun, 9 Jan 2011 01:03:55 +0000 (02:03 +0100)
committerBernhard Urban <lewurm@gmail.com>
Sun, 9 Jan 2011 01:03:55 +0000 (02:03 +0100)
tools/dthex2vhdl [new file with mode: 0755]

diff --git a/tools/dthex2vhdl b/tools/dthex2vhdl
new file mode 100755 (executable)
index 0000000..321e314
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# README: Aufruf:
+# $ ./dthex2vhdl <datei.dthex>
+# die Ausgabe kann man dann einfach in sein gewuenschstes VHDL kopieren.
+# alternativ kann man es auch gleich in die entsprechende datei reinpipen:
+# $ ./dthex2vhdl <datei.dthex> >> ../cpu/src/rom_b.vhd
+# dann muss man es im VHDL file nur noch an die richtige position schieben.
+
+# TODO: data memory beruecksichtigen? brauch ma eh nicht fuer bootrom?
+# TODO: .org anweisungen werden nicht beruecksichtigt!
+
+if [ -f "$1" ]; then
+       egrep -e '^1;' $1 | awk -F ';' '{ print "\twhen \"" (dec2bin(NR-1)) "\" => data_out <= x\"" $3 "\"; -- "$4} func dec2bin(i, str,c) { c = 7; while(i) { if (i%2 == 0) { str = "0" str; } else { str = "1" str; } i = int(i/2); c = c - 1;} while(c) { str = "0" str; c = c - 1;} return str; }'
+else
+       echo "$1 existiert nicht oder ist ein directory"
+fi