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

ParseError for User Defined Primitives #113

Open
TheMatt2 opened this issue Oct 25, 2022 · 1 comment
Open

ParseError for User Defined Primitives #113

TheMatt2 opened this issue Oct 25, 2022 · 1 comment
Labels

Comments

@TheMatt2
Copy link

It seems that Verilog user defined primitives are not supported by this parser.

If I put in an example with a user defined primitive, I get an error message.

primitive udp_and (c, a, b);
    output c;
    input a, b;

// in0 in1 sel :  out
    table
//      a b  c
        0 ?: 0;
        ? 0: 0;
        1 1: 1;
   endtable
endprimitive

Using the example parser, I get the following error message:

$ python3 example_parser.py udp_and.v 
Generating LALR tables
WARNING: 183 shift/reduce conflicts
Traceback (most recent call last):
  File "example_parser.py", line 55, in <module>
    main()
  File "example_parser.py", line 45, in main
    ast, directives = parse(filelist,
  File "/usr/local/lib/python3.10/dist-packages/pyverilog/vparser/parser.py", line 2338, in parse
    ast = codeparser.parse()
  File "/usr/local/lib/python3.10/dist-packages/pyverilog/vparser/parser.py", line 2316, in parse
    ast = self.parser.parse(text, debug=debug)
  File "/usr/local/lib/python3.10/dist-packages/pyverilog/vparser/parser.py", line 77, in parse
    return self.parser.parse(text, lexer=self.lexer, debug=debug)
  File "/usr/local/lib/python3.10/dist-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/local/lib/python3.10/dist-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/usr/local/lib/python3.10/dist-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/usr/local/lib/python3.10/dist-packages/pyverilog/vparser/parser.py", line 2268, in p_error
    self._raise_error(p)
  File "/usr/local/lib/python3.10/dist-packages/pyverilog/vparser/parser.py", line 2279, in _raise_error
    raise ParseError("%s: %s" % (coord, msg))
pyverilog.vparser.parser.ParseError:  line:1: before: "primitive"
@shtaxxx shtaxxx added the wontfix label Nov 5, 2022
@shtaxxx
Copy link
Member

shtaxxx commented Nov 5, 2022

Sorry, the current version of Pyverilog does not support primitive.
I think the modification of AST parser is not so difficult if add this feature based on the current parsing function for module.

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

No branches or pull requests

2 participants