- #1
hoheiho
- 47
- 0
Homework Statement
Hi, I am now currently working with a CPU. Now I want to write the RAM's MEM into a .txt file.
Code:
reg [31:0] mem [ 0 : (32'h0000_5000 / 4)-1 ]
// To .txt
integer test_file;
initial
begin
test_file = $fopen("result_file.txt","w");
end
//the MEM part
always @ (posedge wb_clk_i)
begin
if (ram_we)
begin
mem[adr] <= wr_data;
$fwrite(test_file,"%b\n",mem); // I have only added this part
end
end
Then I got an error message : $fwrite : Argument number 3 is an unpacked type, and may only be printed with the '%p' format.
I have tried to change it to %p. But it print out somethings like dec number. I prefer the test_file.txt will got all the binary number from MEM.
Could anyone seen the problem?
Thanks for the help
Ivan