MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
558 stars 122 forks source link

-Wsign-compare and annoying SV limitations of genvar types #1026

Closed MikePopoloski closed 4 days ago

MikePopoloski commented 2 weeks ago

Discussed in https://github.com/MikePopoloski/slang/discussions/1018

Originally posted by **jrudess** June 1, 2024 I've been finding -Wsign-compare to be pretty useful, except when it relates to generate-for loops. Now this isn't really Slang's problem because it's a silly SV limitation going back to verilog-95 that genvar's can't have their types defined and are always integer type. e.g. this code gets a -Wsign-compare warning ``` parameter int unsigned NUM_PORTS = 3; for (genvar i = 0; i < NUM_PORTS; i++) begin end ``` If I try to convert my parameters to 'int' to avoid sign-compare warnings with the generate-loops, then I just get them with comparisons against real 'logic' variables which are also unsigned. My general preference is to fix sign-compare for the logic vars and not fix the warnings for genvar cases. What do you think about a new option to suppress the sign-compare warning only when genvar types are involved? Or maybe to split out genvars so they are not part of -Wsign-compare but maybe -Wgenvar-sign-compare?
MikePopoloski commented 4 days ago

Done in 4dcf49d00c620686681afbf252c5295fa1f38122