s3e: fix build break
[calu.git] / tools / dthex2vhdl
1 #!/bin/bash
2
3 # README: Aufruf:
4 # $ ./dthex2vhdl <datei.dthex>
5 # die Ausgabe kann man dann einfach in sein gewuenschstes VHDL kopieren.
6 # alternativ kann man es auch gleich in die entsprechende datei reinpipen:
7 # $ ./dthex2vhdl <datei.dthex> >> ../cpu/src/rom_b.vhd
8 # dann muss man es im VHDL file nur noch an die richtige position schieben.
9
10 # TODO: data memory beruecksichtigen? brauch ma eh nicht fuer bootrom?
11 # TODO: .org anweisungen werden nicht beruecksichtigt!
12
13 if [ -f "$1" ]; then
14         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; }'
15 else
16         echo "$1 existiert nicht oder ist ein directory"
17 fi