# File writing

**URL:** <https://verificationacademy.com/forums/t/file-writing/36231>\
**Category:** SystemVerilog\
**Tags:** fileread, filewrite, SystemVerilog\
**Created:** [June 27, 2019, 1:40pm UTC](https://verificationacademy.com/forums/t/file-writing/36231 "2019-06-27T13:40:39Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![avinash\_nambiar](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@avinash\_nambiar](https://verificationacademy.com/forums/u/avinash_nambiar)\
**Post date:** [June 28, 2019, 5:11am UTC](https://verificationacademy.com/forums/t/file-writing/36231/5 "2019-06-28T05:11:06Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/file-writing/36231/4):_

Hi Dave, fd1 takes up an integer value -2147483645.  
Apparently, I got it working by changing the code to

```verilog
always @ (posedge clk)
  begin
    if(dut_wvalid)
      begin
        fd1 = $fopen("axi_write.txt","a"); //Opening file for write
        $fwrite(fd1,"%h %h \n",awaddr,wdata);
        $fclose(fd1);
      end
  end

```

But would like to know why it didn’t work in the previous case

---

_[View the full topic](https://verificationacademy.com/forums/t/file-writing/36231)._
