From 5b6a3f3b216939a11ed1978d7da4dd6bbe4edc2a Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Tue, 29 Dec 2020 19:52:00 +0100 Subject: add a C program for translating binary files to format understood by Verilog --- tools/bin2hex.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tools/bin2hex.c (limited to 'tools/bin2hex.c') diff --git a/tools/bin2hex.c b/tools/bin2hex.c new file mode 100644 index 0000000..f4f2745 --- /dev/null +++ b/tools/bin2hex.c @@ -0,0 +1,26 @@ +#include +#include + +int main(int argc, char **argv) +{ + int input; + + while (1) { + input = getchar(); + + if (input == EOF) + break; + + printf("%02x", input); + + input = getchar(); + + /* If we have odd number of bytes, pad with a NULL-byte. */ + if (input == EOF) + input = 0; + + printf(" %02x\n", input); + } + + return 0; +} -- cgit v1.2.3