J
John
Guest
Reading the Verilog-2001 spec, I see that the $fscanf system call
returns the number of successfully matched and assigned input items.
Quote from text on p.293 of Verilog-2001 spec:
The number of successfully matched and assigned input items is
returned in "code"; this number can be 0 in the event of an early
matching failure between an input character and the control string. If
the input ends before the first matching failure or conversion, EOF is
returned.
However, I see different behavior in multiple simulators at the point
where end-of-file is reached when reading the exact same input file.
Specifically:
- Popular simulator-A returns "0" when end-of-file is reached since
there have been zero matches with the pattern in the system call.
- Unpopular simulator-B returns "-1" when end-of-file is reached since
that's the verilog representation for EOF.
Since the file ends immediately after the last correctly formatted
data set, I expected the behavior to be an EOF. Simulator-A caused my
simulation to run forever.
This is just a friendly warning to watch-out for EOF when using
$fscanf.
- John.
returns the number of successfully matched and assigned input items.
Quote from text on p.293 of Verilog-2001 spec:
The number of successfully matched and assigned input items is
returned in "code"; this number can be 0 in the event of an early
matching failure between an input character and the control string. If
the input ends before the first matching failure or conversion, EOF is
returned.
However, I see different behavior in multiple simulators at the point
where end-of-file is reached when reading the exact same input file.
Specifically:
- Popular simulator-A returns "0" when end-of-file is reached since
there have been zero matches with the pattern in the system call.
- Unpopular simulator-B returns "-1" when end-of-file is reached since
that's the verilog representation for EOF.
Since the file ends immediately after the last correctly formatted
data set, I expected the behavior to be an EOF. Simulator-A caused my
simulation to run forever.
This is just a friendly warning to watch-out for EOF when using
$fscanf.
- John.