question about fwrite

C

comp

Guest
hello,
I'm new to the verilog language
I use the 'fwrite' function a lot to make logs for simulation.
However when a file exists, fwrite overwrites the existing file. I
wanted to append data to the existing file. Is there an option to
append data to the existing file instead of overwriting it?

-jungsook
 
On Oct 2, 5:37 pm, comp <jungsook.y...@gmail.com> wrote:
hello,
I'm new to the verilog language
I use the 'fwrite' function a lot to make logs for simulation.
However when a file exists, fwrite overwrites the existing file. I
wanted to append data to the existing file. Is there an option to
append data to the existing file instead of overwriting it?
Just like in C, you need to fopen() the file for "append". E.g.

// See page 167 of the "Verilog Golden Reference Guide", Doulos 2003.
integer fd = $fopen("foo.txt", ra+);

This assumes Verilog-2001 which I hope you are coding to.
--
- Mark
 
mrfirmware wrote:
Just like in C, you need to fopen() the file for "append". E.g.

// See page 167 of the "Verilog Golden Reference Guide", Doulos 2003.
integer fd = $fopen("foo.txt", ra+);
Slight correction: the mode argument must be a string, and append mode
is just "a". So that would be

integer fd = $fopen("foo.txt", "a");

Note that calling $fopen with a mode will return a file descriptor
rather than a multi-channel descriptor. While multi-channel
descriptors can be OR-ed together to get descriptors that will write
to multiple files at once, file descriptors cannot.
 
thanks for your comment.
I tried this $fopen("./filename","a"); and it's saying that "$fopen
system task has illegal arguments" .
ra+ didn't work either.
I'm using VERILOG-XL from cadence.


On Oct 3, 2:14 pm, sh...@cadence.com wrote:
mrfirmware wrote:
Just like in C, you need to fopen() the file for "append". E.g.

// See page 167 of the "Verilog Golden Reference Guide", Doulos 2003.
integer fd = $fopen("foo.txt", ra+);

Slight correction: the mode argument must be a string, and append mode
is just "a". So that would be

integer fd = $fopen("foo.txt", "a");

Note that calling $fopen with a mode will return a file descriptor
rather than a multi-channel descriptor. While multi-channel
descriptors can be OR-ed together to get descriptors that will write
to multiple files at once, file descriptors cannot.
 
On Oct 5, 4:47 am, comp <jungsook.y...@gmail.com> wrote:
thanks for your comment.
I tried this $fopen("./filename","a"); and it's saying that "$fopen
system task has illegal arguments" .
ra+ didn't work either.
I'm using VERILOG-XL from cadence.
The second arg. is Verilog-2001. I would see if you can flag VERILOG-
XL to operate in 2001 mode. Verilog-1995 is archaic.
- Mark
 
mrfirmware wrote:
On Oct 5, 4:47 am, comp <jungsook.y...@gmail.com> wrote:
I'm using VERILOG-XL from cadence.

The second arg. is Verilog-2001. I would see if you can flag VERILOG-
XL to operate in 2001 mode. Verilog-1995 is archaic.
Verilog-XL does not support the Verilog-2001 extensions, except for
signed arithmetic.
 
On Oct 5, 11:15 am, sh...@cadence.com wrote:
mrfirmware wrote:
On Oct 5, 4:47 am, comp <jungsook.y...@gmail.com> wrote:
I'm using VERILOG-XL from cadence.

The second arg. is Verilog-2001. I would see if you can flag VERILOG-
XL to operate in 2001 mode. Verilog-1995 is archaic.

Verilog-XL does not support the Verilog-2001 extensions, except for
signed arithmetic.
I changed the software to ncverilog and appending worked. thanks!
 

Welcome to EDABoard.com

Sponsor

Back
Top