Running a simulation with many rstb toggles seems to eventually hit a 'Too many open files' error as a result of the following code.
Shouldn't the $fopen happen only once at the beginning of the simulation, i.e., on the very first rstb release? The remainder of the simulation should be stuck in the forever loop until the simulation ends, at which point the file should close. Is there any chance that subsequent resets will cause further $fopen's? Or is this a tool issue?
my_file = $fopen("./my.log"), "w"); // always overwrite at beginning of sim
if (my_file == 0) begin
$display("file open failed");
if (valid) begin
$fdisplay(my_file, "some info");