30f2a7d3 |
1 | #!/usr/bin/perl\r |
2 | \r |
3 | # This tool converts a Xilinx xxx.rbt FPGA bitstream to a table that will\r |
4 | # compile as C source code. The output format is DWORDs, MSB first.\r |
5 | \r |
94f6d4a6 |
6 | local $/ = "\r\n";\r |
7 | \r |
30f2a7d3 |
8 | print "// Generated by rbt2c.pl, do not edit!\n\n";\r |
9 | \r |
10 | for(1..7) {\r |
11 | chomp($_ = <>);\r |
12 | print "//// $_\n";\r |
13 | }\r |
14 | \r |
15 | print <<EOT;\r |
16 | \r |
17 | #include <proxmark3.h>\r |
18 | \r |
19 | const DWORD FpgaImage[] = {\r |
20 | EOT\r |
21 | \r |
22 | while(<>) {\r |
23 | chomp;\r |
24 | $v = 0;\r |
25 | for $b (split(//, $_)) {\r |
26 | $v <<= 1;\r |
27 | if($b eq '1') {\r |
28 | $v |= 1;\r |
29 | } elsif($b ne '0') {\r |
30 | die;\r |
31 | }\r |
32 | }\r |
33 | printf("\t0x%08x,\n", $v);\r |
34 | }\r |
35 | \r |
36 | print <<EOT;\r |
37 | };\r |
38 | \r |
39 | const DWORD FpgaImageLen = sizeof(FpgaImage) / sizeof(FpgaImage[0]);\r |
40 | \r |
41 | EOT\r |