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

False error for generic initialised with non globally static expression #886

Closed
stieeev opened this issue May 7, 2024 · 2 comments
Closed
Labels

Comments

@stieeev
Copy link

stieeev commented May 7, 2024

hdl.zip

The attached example file top.vhd instantiates work.ram with a generic set to the value INIT_LINE("default.txt"), which is not a globally static expression. nvc 1.12.0 fails this with an error:

** Error: actual associated with generic DFLT_NUM must be a globally static expression
    > C:\awrk\hdl\top.vhd:23
    |
 23 |     DFLT_NUM => INIT_LINE("default.txt")
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^

Questasim 2022.3 doesn't bat an eyelid with this, not even a warning.

I'm not expert in the VHDL standards, but I guess the requirement for globally static expressions applies to ports but not to generics ?

@stieeev
Copy link
Author

stieeev commented May 7, 2024

Saw a Stack Overflow post that seems relevant:

https://stackoverflow.com/questions/57387726/what-is-a-globallylocally-static-primaryexpressionrangesubexpression-and

One interesting usage is - considering an innocent looking footnote in Chapter 9.4 of the standard:

The rules for globally static expressions imply that a declared constant or a generic may be initialized with an expression that is not globally static, for example, with a call to an impure function. The resulting constant value may be globally static, even though its initial value expression is not.

@nickg nickg added the analysis label May 8, 2024
@nickg nickg closed this as completed in 6f319ea May 8, 2024
@nickg
Copy link
Owner

nickg commented May 8, 2024

Yes you're correct, this check is overly strict.

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