In regular Verilog I could write simultaneously to transcript/console and to a file with:
integer targ;
initial begin
targ = $fopen(“output_file.txt”);
…
$fdisplay(3, …);
…
which worked because successive $fopens were assigned single-bit values of 2, 4, 8, etc., whereas transcript was automatically assigned a value of 1
With SystemVerilog $fopen handles start at 32’h80000003 and continue with 32’h80000004, etc., so I can no longer OR two powers of 2 together to write to two destinations at once.
What is the trick in SystemVerilog to write simultaneously to file and transcript (or to two different files, for that matter?)?
BTW, this was a Verilog-2001 addition, nothing to do with SystemVerilog.
What matters is if you use $fopen with one argument (“the file name”), or use a second argument (“a type descriptor”)
With one argument, $fopen returns a 32-bit multichannel file descriptor with bits 0 and 31 reserved. Bit-0 is reserved for standard output, and bit-31 is always 0. The other 30 bits are assigned to 30 different files and combined with the standard output. There is no defined ordering of those 30 bits.
With two arguments, $fopen opens as may files as your operating system will allow. Bit-31 is set to 1 and you cannot combine file descriptors.