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

Fix Verilator Warnings in bsg_mem and bsg_misc #693

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

Conversation

infinitymdm
Copy link
Contributor

@infinitymdm infinitymdm commented Sep 6, 2024

Non-functional changes in bsg_mem and bsg_misc to fix Verilator lint warnings and 1 syntax error.

  • bsg_mem/bsg_mem_multiport_latch_write_banked_bypassing.sv: Fix syntax error due to mismatched end. Looks like it should have been commented out with the rest of the block above it.
  • bsg_misc/bsg_mul.sv: Fix incorrect port name. Fixes Verilator PINMISSING warning.
  • bsg_mem/bsg_mem_2rw_sync.sv: Fix misleading indentation of assert ... else blocks. Fixes Verilator MISINDENT warnings.
  • bsg_mem/bsg_mem_1r1w.sv: Cast parameter to appropriate length before comparison with logic. Fixes Verilator WIDTHEXPAND warning. Also disable verilator UNSIGNED warning on this comparison.
  • bsg_misc/bsg_counter_overflow_en.sv: Cast parameter to appropriate length before comparison with logic. Fixes Verilator WIDTHEXPAND warning.

@taylor-bsg
Copy link
Contributor

The Verilator warnings are an interesting case. I am not sure about casting the values to ints since they are 32-bit signed.

@taylor-bsg
Copy link
Contributor

ChatGPT:

  1. Type Conversion and Overflow Logic:
    • The line assign overflow_o = (int'(count_o) == max_val_p); uses int'() type casting, which is likely not necessary and could be replaced with ptr_width_lp'() to match the width of count_o:
      assign overflow_o = (count_o == ptr_width_lp'(max_val_p));
    • This avoids unnecessary type conversions and potential mismatches.

@infinitymdm
Copy link
Contributor Author

infinitymdm commented Sep 9, 2024

I'm thinking the clearest way to do this will be to apply the BSG_WIDTH macro for casting in both files where there's an affected comparison. That seems clearer to me than using ptr_width_lp, at least (though I admit it's a little less efficient for the preprocessor), and provides a way to do this in both files with the WIDTHEXPAND warning. Expect an updated PR shortly.

EDIT: using BSG_WIDTH generated a whole new bevy of warnings, so we're falling back to what ChatGPT suggested (though I still think this is less clear)

@infinitymdm infinitymdm marked this pull request as draft September 9, 2024 14:47
@infinitymdm infinitymdm force-pushed the master branch 3 times, most recently from 6c66e67 to 368c3ac Compare September 9, 2024 14:55
@infinitymdm infinitymdm marked this pull request as ready for review September 9, 2024 15:18
@infinitymdm
Copy link
Contributor Author

The latest changes are in line with your suggestions, but I worry a bit about the safety of shrinking els_p rather than expanding w_addr_i in bsg_mem_1r1w. Especially with the new UNSIGNED warning.

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