Hi,
I am using Cadence ICADVM20.1-64b.200.21 with SPECTRE20.1.231.isr6 64bit.
In my VerilogA module, I am trying to write some values to a file after the simulation ends.
In order not to overwrite the file if it already exists, I first check if the file exists by opening it for reading and checking the returned multi-channel descriptor "fid".
If "fid" returned is not zero, it means a file with a similar name already exists. So, the filename is changed by appending a number at the end, and the trial is repeated in a while loop. Each trial the number is incremented.
At the final step, I create the file by opening it but now for writing.
Each time a file is opened, I make sure it is closed.
The code works fine and creates "file_with_saved_values.I0.vals". The next run when it finds this file, it successfully creates another file "file_with_saved_values_1.I0.vals" and a third one with the third run "file_with_saved_values_2.I0.vals"
For some reason, on trying to do this further, I get an error:
Failed to run the simulation because one Verilog-A $fopen statement has been used to open more than one file. The number of $fopen statements should be more than the number of files to be opened. Specify the correct number of $fopen statements and rerun the simulation.
I simplified the code and testbench (both attached) and reproduced the same error.
Is there something I am doing wrong when using $fopen? What is special about looping exactly 3 times before giving the error?
Best regards,
Ahmed
code
community.cadence.com/.../fopen_5F00_issue_5F00_va.txt
netlist
community.cadence.com/.../fopen_5F00_issue_5F00_netlist.txt