X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/974ba9a205c5a46dfe213e3493794293ff502945..30f2a7d38fd35b2427a7eb42e1cd75fb1105f927:/tools/rbt2c.pl diff --git a/tools/rbt2c.pl b/tools/rbt2c.pl new file mode 100644 index 00000000..949c9ae9 --- /dev/null +++ b/tools/rbt2c.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +# This tool converts a Xilinx xxx.rbt FPGA bitstream to a table that will +# compile as C source code. The output format is DWORDs, MSB first. + +print "// Generated by rbt2c.pl, do not edit!\n\n"; + +for(1..7) { + chomp($_ = <>); + print "//// $_\n"; +} + +print < + +const DWORD FpgaImage[] = { +EOT + +while(<>) { + chomp; + $v = 0; + for $b (split(//, $_)) { + $v <<= 1; + if($b eq '1') { + $v |= 1; + } elsif($b ne '0') { + die; + } + } + printf("\t0x%08x,\n", $v); +} + +print <