This is a good candidate for filing as a bug report in the bugs
database. I agree that it appears wrong, so by all means file it.
Roger Williams wrote:
> Using Icarus Verilog version 0.9.devel ($Name: s20070227 $),
> $fscanf and $sscanf don't correctly return the number of input arguments
> successfully matched by the specified format, as defined in Std 1364-2001:
>
> 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...
>
> Instead, they always return the argument count, even if none of them were
> matched in the input. The behaviour can be readily demonstrated:
>
> $ cat bar.v
> `define EOF -1
>
> module bar;
> integer line, rc, file, a, b, c;
> reg [8*256:1] str;
>
> initial begin
> file = $fopen ("bar_tests.v_vec", "r");
> if (file == 0)
> $finish;
> for (line = 1; line <= 5; line = line + 1) begin
> rc = $fgets (str, file);
> if (rc == `EOF)
> $finish;
> rc = $sscanf (str, "%h %h %h\n", a, b, c);
> $display ("\tLine %d matches %d args: %h %h %h", line, rc, a,
> b, c);
> end
> $fclose (file);
> $finish;
> end
> endmodule
>
> $ cat bar_tests.v_vec
> 0 1 2
> 3 4 5 // comment at end
> 6 7
> // another comment
> 9 a b
>
> $ iverilog -obar.vvp -tvvp bar.v; vvp bar.vvp
> Line 1 matches 3 args: 00000000 00000001 00000002
> Line 2 matches 3 args: 00000003 00000004 00000005
> Line 3 matches 3 args: 00000006 00000007 00000000
> Line 4 matches 3 args: 00000000 00000000 00000000
> Line 5 matches 3 args: 00000009 0000000a 0000000b
>
> I would expect the behaviour I observe when I compile the same code with
> ModelSim:
>
> # Line 1 matches 3 args: 00000000 00000001 00000002
> # Line 2 matches 3 args: 00000003 00000004 00000005
> # Line 3 matches 2 args: 00000006 00000007 00000005
> # Line 4 matches 0 args: 00000000 00000007 00000005
> # Line 5 matches 3 args: 00000009 0000000a 0000000b
>
--
Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev