[verilog] write the answer in .txt using $fwrite

  • Thread starter hoheiho
  • Start date
  • #1
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
 

Answers and Replies

Related Threads on [verilog] write the answer in .txt using $fwrite

  • Last Post
Replies
0
Views
2K
Replies
1
Views
1K
  • Last Post
Replies
0
Views
8K
  • Last Post
Replies
0
Views
2K
Replies
2
Views
432
Replies
4
Views
3K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
6
Views
3K
  • Last Post
Replies
1
Views
13K
Top