Separate logfiles for checkers

I have a checker that I bind to a module and I’m performing various checks, including assertions as well as some monitoring that I’d like to pipe into a dedicated logfile. I naively used $fopen in an initial procedure as I would normally do in a module, but get an error from my simulator (X…) that says it’s not allowed as per IEEE1800-2012 17.5.

The code looks like this:


checker mychecker (
  input a,
  input b
)
integer fd;
initial begin
  fd = $fopen("mychecker.log", "w");
end

// do some $fdisplay(fd, "blabla");
final begin
  $fclose(fd);
end
endchecker

There must be a way to have a log for the checker right? Unfortunately I haven’t found many resources on checkers out there.

In reply to abasili:

Actually that was easier than I initially thought: (using a variable declaration assignment)


checker mychecker (
  input a,
  input b
);
  integer fd = $fopen("mychecker.log", "w"); 
// do some $fdisplay(fd, "blabla");
endchecker