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

FuseSoC and Github Linter Action #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wallento
Copy link

@wallento wallento commented Jun 17, 2020

This adds a Github action that will automatically check pushes to the repository and pull requests. It will fail when the Verilator linter issues any warning. I propose to use this to have committers either suppress the warnings or add a meaningful message in the waiver file.
You can find a writeup about waiver files in Verilator here: https://wallento.cs.hm.edu/post/20200612-verilator-waivers/
A demo of what the Linter Action produces can be found here for the ibex core, the clou are the source annotations which make it really powerful:

The waiver file looks ugly now, but I see a good path forward solving or waiving the warnings correctly, happy to chat about it.
You don't need to do anything except merging, Actions are a builtin.

This seems to have changed
When using the verilator linter, we want to see all warnings, but not
have it fail on the warnings (for now).
Verilator now supports waivers for the linter to suppress known and
tolerated warnings. It is too ambitious to solve all Linter warnings
for now, but lets start with a waiver file that waivers all warnings
we see so far.

This file was generated by calling fusesoc and then cleaned up.

    fusesoc --cores-root=. run --target=lint
    chipsalliance.org:cores:SweRV_EL2 --verilator_options
    "--waiver-output verilator_waiver.vlt"

From now on the linter should warn about new warnings, and be pedantic
about it.
This adds the Github Linter Action to be invoked on every push or pull
request. It will lint the core and fail when the linter emits any
warnings not suppressed by the waiver file.

I suggest to not revert the "no-fatal" for now and be pedantic, a
linter warning should either be solved or a meaningful entry to the
waiver file added.
@olofk
Copy link
Collaborator

olofk commented Jun 17, 2020

This looks great and will be very useful to keep up code quality. Hopefully we cam reduce the number of existing warnings too. There are quite a few of them but EH1 was verilator clean IIRC so it should be doable

@wallento
Copy link
Author

Yeah, I skipped through them. My gut feeling is that half of them are solved easily within an hour (hidden names, widths, etc.)

@agrobman
Copy link

agrobman commented Jun 17, 2020 via email

@wallento
Copy link
Author

That is not what this PR is about, to be frank. At the moment you are suppressing warnings at simulation build. A linter flow will help improve the code quality and not suppress warnings, this is just to kick start a new flow. Plus this PR adds a CI check for new code and code proposals not to add new Linter failures.

@agrobman
Copy link

agrobman commented Jun 17, 2020 via email

@wallento
Copy link
Author

Sorry, @agrobman, but you clearly miss the point. It has nothing to do with SV compliance. If you have any problem with the synthesizable part of SV not working with Verilator, I encourage you to open an issue with Verilator, it will probably be resolved quickly. Both Swerv and Verilator are part of CHIPS Alliance, so there should be a mutual interest here.
So, you say none of the linting tools gives you any warnings. Did you actually check the output of Verilator?
Just some random picks out of the 514 warnings:

%Warning-UNUSED: ../src/chipsalliance.org_cores_SweRV_EL2_0/design/ifu/el2_ifu.sv:255:10: Signal is not driven, nor used: 'ifc_fetch_req_f_raw'
                                                                                        : ... In instance el2_swerv_wrapper.swerv.ifu
  255 |    logic ifc_fetch_req_f_raw;

The signal is defined and not used. Why define it? What purpose does it serve? Spyglass doesn't mention it?

%Warning-VARHIDDEN: ../src/chipsalliance.org_cores_SweRV_EL2_0/design/ifu/el2_ifu_bp_ctl.sv:648:18: Declaration of signal hides declaration in upper scope: 'j'
  648 |         for (int j=0; j< LRU_SIZE; j++) begin
      |                  ^
                    ../src/chipsalliance.org_cores_SweRV_EL2_0/design/ifu/el2_ifu_bp_ctl.sv:309:15: ... Location of original declaration
  309 |    genvar     j, i;
      |               ^

Is it really a great idea to use the same identifier again?

%Warning-WIDTH: ../src/chipsalliance.org_cores_SweRV_EL2_0/design/lib/el2_lib.sv:39:15: Bit extraction of var[9:2] requires 4 bit index, not 2 bits.
                                                                                      : ... In instance el2_swerv_wrapper.swerv.ifu.bp.f1hash
   39 |    assign hash[pt.BTB_ADDR_HI:pt.BTB_ADDR_LO] = pc[pt.BTB_INDEX1_HI:pt.BTB_INDEX1_LO] ^
      |          

Is the variable actually defined correctly?

So, to come to an end, I genuinely don't care. This is just a service. If you don't believe in style linting at all or have your demo run without trashing the terminal with 514 warnings, fine.
Feel free to close the issue, I have no intention to lecture you about code style. But please try to better understand what Verilator Linter warnings are, I am pretty confident that the majority of the warnings are very legitimate. "Necessary" for "industry-grade" cores? Not sure. But "Hopefully Verilator will evolve and thus won't warn legitimate code..." is an entirely incorrect characterization of the "problem".

@olofk
Copy link
Collaborator

olofk commented Jun 18, 2020

I see two benefits with this patch.

  1. Currently there are so many warnings so that there is no choice but to turn them off, which is always a bad thing. This brings a handy list to go through. Most of these are probably harmless and can be waived, but just like @wallento I noticed undriven signals and width mismatches that can definitely cause problems. This is an opportunity to increase code quality

  2. This currently waives the current list of warnings. Going forward, this means that any new warnings would be spotted immediately which is a safeguard against decreases in code quality

@aprnath
Copy link
Collaborator

aprnath commented Jun 18, 2020

Hi Stefan and Olof,
Thanks for PR and the comments/justifications. Agreed that an itemized waiver list is better than blanket disabling of linter checks. We'll discuss ramifications and respond.

Thank you.

@agrobman
Copy link

@wallento,

What verilator version are you using?

@wallento
Copy link
Author

@aprnath thanks, just drop me a mail if you have any questions or want to discuss it in general.
@agrobman Verilator 4.036. It is based on our docker image (2020.06-rc2, to be released soon): https://github.com/librecores/ci-docker-image

@wallento
Copy link
Author

From verilator/verilator#2433 where @agrobman asked:

I don't understand what do you want.

You started all this complaining that you got a lot of warnings and we don't run lint.
I explained what we don't see any warnings and why.
I didn't say if I want to use verilator lint or not. I knew nothing about verilator lint at time of our
release. I know that commercial simulators issue errors and warnings.
Our check in policy is "no simulator warnings". And we followed it.

I guess -Wno-WIDTH is less masking lint problems than -Wno-lint, so we used this one.
BTW, we consulted with Winston at release time how to suppress these warnings and we followed his advice.

You can't complain that we used older tool version 3 months ago, than one you use now and we even don't know exists.

How do you want us to handle your PR? with what verilator version? Is the latest clean from "bogus" width warnings? If not, when will we get "clean" one?

I think those questions are mostly answered in the commits and above.
The path forward is simple:

  1. You want this push and PR linter checks and think they are good and want to make sure what you are doing on a warning-by-warning basis and gradually wipe the waiver file: merge now.
  2. You think its generally a good idea and are happy to get such contributions, but don't feel its worth the effort now: keep it open with adding an acceptance criteria for another round of dicussions.
  3. You think the Verilator linter is bad and your workflow and the project will not benefit from it whatsoever: Close it, but your learning could be that -Wno-lint is your "friend".

My suggestion is 2.

@agrobman
Copy link

I agree with 2) too. Let us know good verilator version to start with.

@wallento
Copy link
Author

When anyone from your team finds time and patience, I encourage you to post WIDTH warnings here that you believe are entirely wrong or way too pedantic. I will go through them too, but some prioritization of reviewing them is helpful.

@agrobman
Copy link

the big one is sized parameters, I mentioned in verilator post. Before I ask designers to look in the warnings I need 'fixed' verilator version. I'd asked them to do this already, but got push back with all these bogus warnings ...

Looking at your paper, I think, I don't like waver solutions for us. Our design evolves /changes too often - line based waiver is too much maintenance.
(Is waiver line number based?)
I prefer no warnings by construction solution or lint comments for us.

BTW, will lint disable comments work with -f verilog option?

if compilation files list contains
...
disable_lint_file
design_file1
...
design_fileN
enable_lint_file
...

where "disable_lint_file" and "enable_lint_file" contain lint disable and enable comments?

to disable linting in part of the design files without touching them...

@kgugala kgugala changed the base branch from master to main December 13, 2022 18:32
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.

None yet

4 participants