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

`include directive should be allowed anywhere #128

Open
DanChianucci opened this issue Aug 23, 2021 · 8 comments
Open

`include directive should be allowed anywhere #128

DanChianucci opened this issue Aug 23, 2021 · 8 comments

Comments

@DanChianucci
Copy link

Currently I get an extraneous input error if the `include is anywhere except file scope.

ie) With UVM, it is common for the uvc package to simple contain includes for individual classes

package my_uvc_pkg;
  `include "transaction_class.svh"   //<-- Error seen here because parser is not expecting `include
  `include "monitor_class.svh"
  // etc...
endpackage
@DanChianucci
Copy link
Author

It looks like this same issue extends to all compiler directives.
ie
`uvm_component_utils(my_component)

@joecrop
Copy link
Collaborator

joecrop commented Nov 1, 2021

@DanChianucci do you know what is generating the error? Are you using Verilator? If so, it is known to crash hard on most UVM syntaxes. Please see #31.

@DanChianucci
Copy link
Author

The bundled antlr parser is generating the error

@joecrop
Copy link
Collaborator

joecrop commented Mar 9, 2022

Hi @DanChianucci, I finally got around to this. I don't think the problem is the include inside a package. When I rename the file to be transaction_class.sv (removed the h in the extension) the parser is happy. Can you confirm this? If so, this is an easy fix. This file compiles with no errors for me:

package my_uvc_pkg;
    `include "transaction_class.sv"
    `include "monitor_class.sv"
    // etc...
endpackage

class joe extends uvm_object;

    `uvm_object_utils(joe);

    function new(string name = "joe");
        super.new(name);
    endfunction: new
    
enclass joe 

@DanChianucci
Copy link
Author

Changing from .svh to .sv fixes Issue #127
ie. "missing FILENAME at '"transaction_class.svh"'

but not the error I am talking about in this issue
ie. extraneous input "`include"

@joecrop
Copy link
Collaborator

joecrop commented Mar 14, 2022

Thanks @DanChianucci, I am able to reproduce this now. There are quite a few places that are missing allowance of includes. I'll try and capture as many as I can find.

@niciki-niciki
Copy link

niciki-niciki commented Nov 7, 2022

always @( * ) begin
  if ( cond1 ) begin
    case ( sig_key )
      `DEF_CASE1 : sig_name <= 8'b0;
      `DEF_CASE2 : sig_name <= 8'b1;
      default : sig_name <= 8'b1;
    endcase
  end
end

Gives "no viable alternative at input" for:
`DEF_CASE1,
`DEF_CASE2 and
default

It seems that ` sign and default are problems here.

@niciki-niciki
Copy link

niciki-niciki commented Nov 7, 2022

When instantiating module and using some

...
  .port_name ( `DEF_VAL ),
...

for constant port value - I also get "no viable alternative at input" for ` sign

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

No branches or pull requests

3 participants