8bitworkshop
8bitworkshop copied to clipboard
Verilog: $readmemb causes TypeError: code.replace is not a function
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.
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.