Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error on generate begin #50

Closed
flaviens opened this issue Oct 25, 2022 · 3 comments · Fixed by OpenPOWERFoundation/a2o#18
Closed

Parse error on generate begin #50

flaviens opened this issue Oct 25, 2022 · 3 comments · Fixed by OpenPOWERFoundation/a2o#18

Comments

@flaviens
Copy link

flaviens commented Oct 25, 2022

Hi there!

Morty throws a parse error on this file:

module mymodule (
    y,
    a,
    b
);
  parameter WIDTH = 1;
  output [0:WIDTH-1] y;
  input [0:WIDTH-1] a;
  input [0:WIDTH-1] b;

  genvar i;

  generate
    begin : t
      for (i = 0; i < WIDTH; i = i + 1) begin : w

        assign y[i] = a[i] ^ b[i];

      end  // block: w
    end

  endgenerate
endmodule

The error message is

Error: parse error
   --> main.v:14:10
   |
14 |     begin : t
   |          ^
Error: Parse error: Some(("main.v", 168))

Unfortunately the a2o repository is full of such occurrences.

Thanks!

@zarubaf
Copy link
Collaborator

zarubaf commented Oct 25, 2022

I think the begin is not legal SystemVerilog. It is generate/endgenerate (https://www.systemverilog.io/generate). Or http://courses.eees.dei.unibo.it/LABMPHSENG/wp-content/uploads/2016/02/SystemVerilog_3.1a.pdf A.4.2.1 Generated module instantiation.

@flaviens
Copy link
Author

Hi Florian, thank you for your answer!

Given that this pattern is present in the wild and accepted by other tools (I tried Verilator for example), do you think it should be accepted by Morty as well?

@flaviens flaviens reopened this Oct 25, 2022
@micprog
Copy link
Member

micprog commented Oct 25, 2022

This error is from the parser, indicating an error in your code. It seems the begin : t and corresponding end of your code are not spec-compliant. Removing these should fix your issue, although I see the repository you have linked is deprecated.

Morty uses sv-parser to parse the files, which analyzes all files according to the systemverilog specification. Unfortunately we will not modify morty to work around the parser or work to patch the parser for not spec-compliant code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants