sv-parser icon indicating copy to clipboard operation
sv-parser copied to clipboard

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

Open maor1993 opened this issue 10 months ago • 4 comments

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.

maor1993 avatar Feb 26 '25 21:02 maor1993

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(),
  ))
));

dalance avatar Feb 27 '25 00:02 dalance

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 avatar Feb 27 '25 02:02 maor1993

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 avatar Feb 27 '25 11:02 maor1993

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 avatar Feb 27 '25 13:02 maor1993