1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Sep 7, 2012 #1
    1. The problem statement, all variables and given/known data
    Hi, I am now currently working with a CPU. Now I want to write the RAM's MEM into a .txt file.

    Code (Text):
    reg [31:0]  mem [ 0 : (32'h0000_5000 / 4)-1 ]

      // To .txt
       integer      test_file;
          test_file = $fopen("result_file.txt","w");

    //the MEM part
       always @ (posedge wb_clk_i)
        if (ram_we)
          mem[adr] <= wr_data;
          $fwrite(test_file,"%b\n",mem);    // I have only added this part
    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
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted