Hello,
I’m trying to do a binary dump of large 8 bit logic array into a file. I’ve run into these 2 problems:
- Anytime I try to write character 8’h00, it gets replaced with character 8’h20.
- Anytime I try to write character 8’h0A, 2 characters come out, first 8’h0D, then 8’h0A.
Here is an example test code:
integer fout_pointer;
fout_pointer= $fopen("test_file.bin","w");
for (int i=0;i<256;i++) $fwrite(fout_pointer,"%s",8'(i)) ;
$fclose(fout_pointer);
This code is supposed to generate a file where if I analyze it with a hex editor, it should go from 8’h00 the 8’hFF. But, the 8’h00 position has an 8’h20 and the 8’h0A position has a 8’h0D instead, then the 8’h0A comes next.
A larger test dumping a larger array such as:
logic [7:0] array_table [0:65535] = '{8'h##, 8'h##, 8'h##, ..... };
Reveals every 8’h00 is replaced with 8’h08, and every 8’h0A has a new byte 8’h0D placed in just before the 8’h0A.
Is there a way to binary dump/write that array_table into a file. And I do not mean an ascii file with binary or hex values written as text in it. I mean a true data .bin file.
Thanks,
BrianHG.