sv-parser icon indicating copy to clipboard operation
sv-parser copied to clipboard

fix event control asterisk to accept whitespace between @ and *

Open yousifBilal opened this issue 1 year ago • 4 comments

This is a fix for EventControlAsterisk to have 2 symbols @ and *. Most compilers seems to accept a whitespace between @ and *. This module was not being parsed with sv-parser. While others like https://sv-lang.com/explore/ and verilator considered it valid.

module test;
    reg a, b;
    reg out; 

    always @ * begin
        out = a & b;
    end

    always @* begin
        out = a | b;
    end
    initial begin
        // Initialize inputs
        a = 0; b = 0;
        #10; a = 1; b = 0;
        #10; a = 0; b = 1;
        #10; a = 1; b = 1;
        #10; $finish;
    end

    initial begin
        $monitor("At time %0t: a = %0b, b = %0b, out = %0b", $time, a, b, out);
    end
endmodule

yousifBilal avatar Oct 02 '24 08:10 yousifBilal

Thank you for your contribution. This seems to be difficult problem.

According to IEEE1800-2017, the definition of event_control is below. It shows space between @ and * is not allowed.

event_control ::=
@ hierarchical_event_identifier
| @ ( event_expression )
| @*
| @ (*)
| @ ps_or_hierarchical_sequence_identifier

Actually, the following code causes syntax error by Synopsys VCS. We can't request to fix it because it seems to be forbidden by language specification.

always @ /* comment */ * begin
    out = a & b;
end

On the other hand, IEEE1800-2023 is below. It shows space is allowed.

event_control ::=
clocking_event
| @ *
| @ ( * )

So I think the current behaviour should be kept at least to check IEEE1800-2017 compliant. And "IEEE1800-2023 mode" which accepts the space is probably required too.

dalance avatar Oct 03 '24 00:10 dalance

How would realize a "IEEE1800-2023 mode"? would you do it as part of this project or a separate one dedicated for 2023?

yousifBilal avatar Oct 04 '24 07:10 yousifBilal

I don't have enough motivation to create individual project for 2023. So I'll consider about adding mode switch in this project.

dalance avatar Oct 07 '24 00:10 dalance

Could you use Cargo features?

ethanuppal avatar Jan 16 '25 02:01 ethanuppal