keywords:
$open
Syntax:
<file_handle> = $fopen("<file_name");
The default output of a Verilog program normally goes to the standard ouput but this can be redirected to a file.
The file handle mentioned in the syntax above is a 32 bit descriptor. Out of the 32 bits only one bit is high, for the standard output has its least significant bit set. Everytime a call is made to $fopen a new handle is created with the next bit to the left is set to high. So the first call would set the 2nd least significant bit, the second call would set the bit next to that, and so on.
Below is an example showing how to open files.
integer handleA, handleB; // an integer has 32 bits so is perfect // for this usage initial begin handleA = $fopen("myfile.out); // handleA = 0000_0000_0000_0000_0000_0000_0000_0010 handleB = $fopen("anotherfile.out"); // handleB = 0000_0000_0000_0000_0000_0000_0000_0100 end