8bitworkshop icon indicating copy to clipboard operation
8bitworkshop copied to clipboard

Verilog: $readmemb causes TypeError: code.replace is not a function

Open stt opened this issue 5 years ago • 1 comments

Using $readmemb to read a binary file ends up trying to run compileInlineASM on it with "code" being Uint8Array, which doesn't have .replace() causing the exception.

stt avatar Nov 16 '20 01:11 stt

I think the problem is that $readmemb() expects a text file of base-2 numbers, not a binary file: https://athena.ecs.csus.edu/~changw/class_docs/VerilogManual/memory.html

It'd be nice to include binary files in Verilog, but the Verilator tool doesn't support it. Your best bet for now is to convert to a hex dump and use $readmemh(): https://maidavale.org/blog/converting-binary-to-hex-file-for-verilog-readmemh/

This is confusing enough that I should add a proper error message, though.

sehugg avatar Nov 25 '20 16:11 sehugg