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

WIP:preparser: adding 2 optional compiler directives delay_mode_path , delay_mode_distributed #110

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maor1993
Copy link

These 2 compiler directives are defined in Annex E of the 1800-2017

I ran into this while attempting to parse some stdcell libraries.
I unfortunately can't seem to add all of the annex directives as the nom crate seems to have an issue
digging deeper when attempting to use the alt function in sv-parser-parser/src/general/compiler_directives.rs:L9
the nom alt function supports only up to 21 elements, placing all of them breaks this.

regardless, without these two directives I can't parse said Verilog.

@dalance
Copy link
Owner

dalance commented Feb 27, 2025

Thank you for your contribution!
I forgot the detailed usage of nom, could you use nested alt to avoid the element limit like below?

let ret = alt((
  alt((
    map(),
    map(),
  )),
  alt((
    map(),
    map(),
  ))
));

@maor1993
Copy link
Author

I'll try this tomorrow :)

Thank you for your contribution! I forgot the detailed usage of nom, could you use nested alt to avoid the element limit like below?

let ret = alt((
  alt((
    map(),
    map(),
  )),
  alt((
    map(),
    map(),
  ))
));

@maor1993
Copy link
Author

Yup, cascading alts worked 🥳
I added back delay_mode_unit and delay_mode_zero

I will mention this commit misses support for default_trireg_strength and default_decay_time as they might need a new literal? (default decay time valid values are either integerconst, realconst or the word infinite)

@maor1993
Copy link
Author

I've done some more testing and It seems I've implemented something slightly wrong here, when I have a file with one of these directives defined and a module defined afterwards it seems to break the syntax tree.

@maor1993 maor1993 changed the title preparser: adding 2 optional compiler directives delay_mode_path , delay_mode_distributed WIP:preparser: adding 2 optional compiler directives delay_mode_path , delay_mode_distributed Feb 27, 2025
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 this pull request may close these issues.

2 participants