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

Add new features to slang-tidy #776

Closed
wants to merge 150 commits into from
Closed

Add new features to slang-tidy #776

wants to merge 150 commits into from

Conversation

Sustrak
Copy link
Contributor

@Sustrak Sustrak commented Jun 22, 2023

This PR adds new features to slang-tidy:

  • slang-tidy can read its configuration from a .slang-tidy file, closely similar to what .clang-tidy offers.
  • Adds new checks to the linter.
  • Small refactor in the code of the checks.
  • Add option to skip linting checks from specific files.

This PR also adds a new tool: include/slang/util/CppTypePrinter.h

Sustrak and others added 30 commits June 3, 2023 13:39
With this commit the checks and configurations of the slang-tidy tool can be specified using a config file.
This new check will report an error if it finds an always_latch on the
design.
Instead of creating a new diagnostic engine and client, use the one
provided by the driver.
This new check, checks for use of old verilog syntax of always_comb and
always_ff.
Also minor refactors here and there
Also minor refactors here and there
* pyslang.h: correct file reference in leading comment

* Python bindings: expose a visitor pattern

Expose visit methods on pyslang Expressions, Statements, and Symbols.
This method is modelled after MLIR's visitor pattern wherein
callbacks can signal certain actions on the walk, such as
interrupting (i.e., stopping entirely), skipping child nodes,
or to advance.

This commit includes no tests, as pyslang tests are not included
in the slang repo, but in the pyslang repo. Once this commit
is visible to pyslang, tests will be added there.

Here is an example test case that could be added, modelled off
slang/tests/unittests/VisitorTests.cpp:

```
from pyslang import *

tree = SyntaxTree.fromText(
  """
module m;
  int j;
  initial begin : asdf
    j = j + 3;
    if (1) begin : baz
      static int i;
      i = i + 2;
      if (1) begin : boz
        i = i + 4
      end
    end
  end
endmodule
""")

class Visitor:
  def __init__(self):
    self.stmt_ct = 0
  def visit(self, node):
    if isinstance(node, Statement):
      self.stmt_ct += 1

c = Compilation()
c.addSyntaxTree(tree)
v = Visitor()
c.getRoot().visit(v.visit)
assert v.stmt_ct == 11
```
MikePopoloski and others added 29 commits June 24, 2023 21:30
This check will trigger a warning if a non-blocking assignment is used
inside an always_comb block
Check that there is no use of blocking assignments inside an always_ff,
for variables that represent a register. Only allowed blocking
assignments are those used in local variables.
With this commit the checks and configurations of the slang-tidy tool can be specified using a config file.
@Sustrak Sustrak closed this Jun 25, 2023
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

3 participants