Converting binary to hex file for use with Verilog $readmemh

2020/08/15

Tags: fpga

To convert a binary file to a format acceptable by the Verilog $readmemh call, the linux hexdump command can be used with a custom format string.

For our purposes, a file with one hex digit per line is adequate, we don’t need the file to contain addresses althought the format does support that.

This can be achieved with:

hexdump -v -e '1/1 "%02x\n"' amazonia.scr > amazonia.hex

Another option would be to use the srecord program, which supports the verilog VMEM format: http://srecord.sourceforge.net/man/man5/srec_vmem.html