<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/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($_ = &lt;&gt;);
	print "//// $_\n";
}

print &lt;&lt;EOT;

#include &lt;proxmark3.h&gt;

const DWORD FpgaImage[] = {
EOT

while(&lt;&gt;) {
	chomp;
	$v = 0;
	for $b (split(//, $_)) {
		$v &lt;&lt;= 1;
		if($b eq '1') {
			$v |= 1;
		} elsif($b ne '0') {
			die;
		}
	}
	printf("\t0x%08x,\n", $v);
}

print &lt;&lt;EOT;
};

const DWORD FpgaImageLen = sizeof(FpgaImage) / sizeof(FpgaImage[0]);

EOT
</pre></body></html>