github MikePopoloski/slang v11.0

3 hours ago

Highlights

This release contains many changes designed to increase compatibility with non-standard extensions and behaviors allowed by commercial tools, along with many new linting and static analysis warnings. It also improves performance and reduces memory usage, includes a number of quality of life features, and fixes many bugs.

As usual, a big thank you to everyone who submitted issues and patches to help improve slang.

Language Compatibility

  • Added a --allow-virtual-iface-with-override flag to allow interface instances that are bind/defparam targets to be assigned to virtual interfaces (thanks to @thomasnormal)
  • The error for invalid arguments to std::randomize has been made downgradeable via -Wnonstandard-randomize (thanks to @AndrewNolte)
  • Added support for conatenating strings with operator '+' (which will now issue -Wnonstandard-string-concat) (thanks to @AndrewNolte)
  • The error for nested block comments is now a warning by default (-Wnested-comment), and turned off by default in VCS compat mode
  • extern and pure method prototypes are now allowed to have an implicit return type (thanks to @mampcs)
  • The error for qualifiers on out-of-block method definitions is now downgradeable via -Wqualifiers-on-out-of-block (thanks to @mampcs)
  • The error for missing implementations of extern methods is now downgradeable via -Wmember-impl-not-found (thanks to @mampcs)
  • Unqualified task and function calls will now perform upward name resolution up the hierarchy if there is no declaration visible locally. The LRM is not entirely clear here but all major tools allow this and now slang does as well. (thanks to @mampcs)
  • The error for missing for loop variable initializers is now downgradeable via -Winitializer-required (thanks to @mampcs)
  • The error for use of package imports within class scopes is now downgradeable via -Wpackage-import-in-class (thanks to @mampcs)
  • Made the diagnostics for multiple overlapping assignments downgradeable to warnings (via the new warnings -Wmixed-var-assigns, -Wmultiple-cont-assigns, and -Wmultiple-always-assigns)
  • The string formatting functions now allow passing class handles, chandles, and null literals as arguments to integer format specifiers (thanks to @thomasnormal)
  • Misplaced trailing separator errors are now downgradeable to a warning (via the new warning -Wmisplaced-trailing-separator) (thanks to @thomasnormal)
  • Coverage cross items can now specify another cross as a target (thanks to @mampcs)
  • Coverage cross items can now contain dotted / hierarchical names, flagged via -Wnonstandard-hierarchical-cross (thanks to @AndrewNolte)
  • inside expressions can now specify a single element without the usually required braces, flagged via -Wnonstandard-inside (thanks to @AndrewNolte)
  • foreach array references can now contain function call expressions, flagged via -Wforeach-call-expr (thanks to @mampcs)
  • Added support for the $deposit system task, which is non-standard but very common in older codebases (thanks to @mampcs)
  • --relax-string-conversions now also allows implicit conversions from integers to strings (thanks to @mampcs)
  • Structured assignment patterns can now be written without the leading apostrophe, flagged by -Wnonstandard-bare-assoc-pattern (an error by default) (thanks to @mampcs)
  • Added --allow-array-concat-assign-pattern which allows assignment patterns (which usually require an assignment-like context) to be used in an unpacked array concatenation (thanks to @mampcs)
  • The error for leading underscores in vector literals is now downgradeable via -Wliteral-leading-underscore
  • The error for use of ref args in static functions is now downgradeable via -Wref-arg-automatic
  • The error for concats between strings and ints is now downgradeable via -Wstring-int-concat
  • The error for reversed range select ordering is now downgradeable via -Wrange-select-reversed
  • Default expressions in structured assignment patterns can now themselves be nested assignment patterns
  • Dynamic array new expressions can now have a structured assignment pattern initializer expression
  • Immediate assertions are now correctly disallowed in non-procedural contexts
  • Streaming operators are now allowed as branches of conditional (ternary) expressions (thanks to @likeamahoney)
  • In single-unit mode, named library files still result in their own compilation units (each one a single unit), to better match how other tools partition compilation units when libraries are involved
  • Assertion local variables can now be declared with any bitstream type, not just the types allowed in sequences
  • Invalid nested constraint blocks can now be allowed via -Wnonstandard-constraint-block
  • String format functions can now allow empty arguments and unused trailing arguments via -Wformat-empty-arg and -Wformat-too-many-args
  • The error for trying to override a parameter that doesn't exist is now downgradeable via -Wundefined-param-override
  • The error for mismatching virtual method argument names is now downgradeable via -Wvirtual-arg-name-mismatch
  • The error for indexing a single bit type is now downgradeable via -Wcannot-index-scalar
  • The error for using a ref arg in a fork-join block is now downgradeable via -Wref-arg-in-fork-join
  • The error for referencing a cover cross in a binsof expression is now downgradeable via -Wcross-ident-in-binsof
  • The error for using a string type in constraint expressions is now downgradeable via -Wstring-in-constraint
  • The error for redefining a symbol with the same name in the same scope is now downgradeable via -Wredefinition and -Wredefinition-different-type
  • The error for assigning to the target of a clocking variable is now downgradeable via -Wclockvar-target-assign

Notable Breaking Changes

  • pyslang bindings are now separated into submodules matching the C++ API namespaces, which will require adding imports to your existing scripts to make them continue to run
  • The ASTVisitor template now takes a VisitFlags enum instead of a bunch of bool parameters
  • -Wimplicit-conv has been moved from the default warning set to the -Wextra group due to being a little too noisy for a default. If you want it on and aren't using -Wextra you'll need to readd it to your command line.
  • The LSPUtilities class has been replaced by the more capable ValuePath class. Users of the old API will need to migrate to the new one.

New Features

  • Instantiations of unknown modules can now be ignored by putting a (* maybe_unknown *) attribute on the instantiation itself (thanks to @AndrewNolte)
  • Added -Wread-write and -Wmulti-write for detecting undefined sequencing of operations involving a single variable (both on by default)
  • Added -Wunused-subroutine, -Wunused-dpi-import, -Wunused-class-method, -Wunused-local-class-method, and -Wunused-constructor for detecting various kinds of unused tasks and functions
  • Added -Wunused-class-property, -Wunused-but-set-property, -Wunassigned-property, -Wunused-local-class-property, -Wunused-but-set-local-property, and -Wunassigned-local-property for detecting various forms of unused class properties
  • Added -Wunused-package-var, -Wunused-package-typedef, -Wunused-package-parameter, -Wunused-package-type-parameter, -Wunused-package-assertion-decl, and -Wunused-package-subroutine for detecting unused items declared inside packages
  • -Wunconnected-port has been split into three separate warnings: -Wunconnected-input-port, -Wunconnected-output-port, and -Wunconnected-inout-port, for more precise control over which warnings you want to see. The original -Wunconnected-port is now a group that controls all three at once, so existing command lines should continue to function the same way.
  • Added -Wempty-input-connection, -Wempty-output-connection, and -Wempty-inout-connection (grouped under -Wempty-connection) which warn about port connections that are explicitly connected to nothing
  • Added -Wrandomize-var-shadow which detects inline randomize constraint blocks that use class members which shadow local variable declarations
  • Added -Wshadow-value and -Wshadow-hierarchy which detect declarations that shadow others with the same name from outer scopes
  • Added -Wshadow-property which warns about class properties that shadow members of a base class
  • Added -Winc-dec-bit which detects increment and decrement of single-bit operands
  • Added -Wdangling-else which detects confusingly nested if/else blocks that are missing begin/end delimiters
  • Added -Wshift-count-overflow and -Wshift-count-negative which warn about potentially invalid constant shift values
  • Added -Wconstraint-func-cycle and -Wonstraint-solve-cycle which warn about potential cycles in constraint function calls and solve-before directives
  • Added -misleading-indentation which warns about statements that are indented in a way that makes them look like they belong to a preceding loop or condition when they actually don't
  • Added -Wnewline-eof which warns for files that do not end in a newline character
  • Added -Wdynamic-cast-const which warns for uses of $cast that are statically known to always succeed or always fail
  • Added -Wupward-name which warns for uses of upward hierarchical names
  • Added -Wfork-loop-var which warns for suspicious uses of for or foreach loop variables inside nested fork-join blocks
  • Added -Wloop-var-modify which warns for suspicious modifications of for loop variables inside the loop body
  • Added -Wloop-cond-not-modified which warns when none of the variables in a for loop condition are modified by the loop itself
  • Added -Wnull-port which warns for declarations of non-ANSI "null" ports
  • Added -Wdivide-by-zero which warns when the right hand side of a division or modulo operator is a constant zero
  • Added -Wcolon-plus which warns about the sequence :+ inside a range select expression, where probably the intent was to use +: for ascending selection
  • Added -Winit-self when a variable's initializer refers to itself
  • Added -Wbits-of-integer-constant which warns about bugprone use of $bits on integer constants (thanks to @AndrewNolte)
  • Added a --dir-prefix option to specify directory prefixes to try when resolving relative source file paths
  • Added a --max-enum-values option that limits the maximum number of enum elements in a single declaration, to prevent typos in enum range members from causing the compiler to run out of memory
  • Added --max-constant-size which allows controlling the maximum size of constant values allocated during elaboration, to avoid runaway compiler memory usage
  • The --cst-json-mode flag takes a new option no-whitespace which includes trivia but filters out whitespace and newlines (thanks to @AndrewNolte)
  • The preprocessor now detects the common `ifndef / `define header guard pattern and avoids opening the include file entirely if it sees an include directive for it again. Also added -Wheader-guard which detects potential mistakes in the header guard names.
  • Added a new flag --allow-macro-trailing-space which allows trailing whitespace after line continuations in macro definitions (thanks to @mampcs)
  • Compilation unit listings now accept local -W settings to control warnings issued for just that compilation unit
  • Added --preprocess-source which includes source file and line info in the output when running the preprocessor standalone, with e.g. --preprocess (thanks to @mampcs)
  • Added --group-macros-by-file which groups macros by file when outputting them via --macros-only (thanks to @mampcs)
  • Added --show-parsed-files which prints debug information about which files are parsed and what kind of file they are (thanks to @mampcs)
  • Added --incdir-first which reverses the include file search order so user-specified directories (+incdir/-I) are checked before the local directory of the including file (thanks to @mampcs)
  • Added --allow-missing-protected-scope-end which allows slang to work around encrypted code blocks in third party headers that mistakenly hide the scope end keyword of their containing module/interface/program (thanks to @mampcs)
  • Added --allow-lib-module-redef which allows redefining a module, interface, program, or primitive with the same name in the same library (thanks to @mampcs)
  • Added --time-stats which prints high-level time profiling stats and peak memory usage when running the slang frontend
  • Added --memory-stats which prints a detailed report of compiler memory usage
  • Added --define-system-task which allows defining custom system tasks and functions via the command line

Improvements

  • Made several improvements to data flow modeling in the analysis pass to better represent SystemVerilog control flow
    • Loop unrolling works in more cases; for loops that did not declare their loop variable but refer to an automatic local variable now work as expected
    • Improved determination of whether a for loop is guaranteed to execute at least once, in cases where step or stop condition expressions are omitted
    • Conditional expressions that have a known ambiguous x condition are now modeled correctly
  • Added AST serialization for default disable directives and default / global clocking block modifiers
  • The error issued for incorrect range select ordering is now suppressed inside conditional blocks that are statically known to be untaken
  • Tweaked the behavior of how --allow-use-before-declare works when there are matching declarations in outer scopes, to better match other tools (thanks to @mampcs)
  • The parser will now perform typo correction when looking for a keyword and finding a closely named identifier instead
  • Dotted lookups will now perform typo correction and provide a note when a closely named member is found
  • The SyntaxRewriter API has gained support for rewriting individual tokens (thanks to @ilthraim)
  • Source location and context are now included when reporting errors in command files and compilation unit listings
  • Made many changes to optimize memory usage -- syntax trees are now significantly more compact, leading to a 20-30% decrease in memory usage for large designs
  • Renamed ConstantRange::isLittleEndian -> isDescending, cleaned up a few other uses of the term 'endian' when refering to bit range ordering
  • slang now properly reports an error if a source file maps to more than one source library with equal priority
  • Made several improvements to how type names are rendered in diagnostic output
  • Improved how large bit vectors that are all Xs or Zs are rendered in diagnostic output
  • defparam and bind resolution now has a prepass that helps filter out irrelevant portions of the design, to optimize performance and memory usage
  • Ports on interfaces that were only referenced by unused modports will now trigger -Wunused-port warnings (thanks to @hankhsu1996)

Fixes

  • Fixed an issue where comments immediately preceeding a disabled `endif directive could erroneously show up in preprocessed output
  • Fixed a preprocessor crash with invalid macro usage syntax when the macro contains a stringify operator
  • Fixed a preprocessor bug where nested macros containing ifdef directives could be expanded improperly
  • Fixed a preprocessor bug during macro expansion when a macro argument immediately follows a line continuation character on a separate line
  • Fixed a bug in macro token concatenation where the second token needs to be split and re-lexed to function properly
  • Fixed a bug where multiple layers of include files originating from within a macro expansion would not expand in the correct order (thanks to @mampcs)
  • Fixed parsing of 1800-2023 preprocessor conditional expressions; precedence and associativity of operators was not handled correctly
  • Fixed macro argument expansion to apply macro ops (such as concatenation) before expanding nested macros
  • Unary increment and decrement operators now properly count as a driver for their operand, for purposes of multi-driver checking
  • Fixed miscompilation when a generic class with a virtual interface type parameter declared within a package triggers an import lookup within that package
  • Fixed a crash when a class declares an extern pre/post_randomize method but doesn't provide a body
  • Fixed a bug where instances of the same generic class were always considered matching even if they had different parameter values
  • Fixed a bug where type parameters of generic base classes could fail to resolve in certain rare cases
  • Fixed a bug where various operations on class types (such as computing their bitstream width) would not take into account base class properties
  • Fixed a bug with looking up the return type of implicit function return value variables when --allow-use-before-declare is used
  • Fixed -Wcomparison-mismatch to not warn when comparing unpacked array types with the same width but differing range indices
  • Fixed data flow analysis to work correctly with locally declared static variables in procedural blocks
  • Fixed string format diagnostic locations when the format string contains escape characters
  • Fixed constant evaluated string formatting when the format string is triple quoted or contains escape characters
  • Fixed the handling of command line provided parameter overrides involving assignment patterns and unpacked array concatenations
  • Fixed constant evaluation of unpacked array parameters set via defparam
  • Fixed a bug in how packed arrays are split across instance array port connections (thanks to @CheeksTheGeek)
  • Fixed ICE from formal argument declarations that have a missing direction due to invalid syntax
  • Fixed a malformed diagnostic when parsing duplicate empty function specifiers
  • Fixed ASTVisitor to visit out-of-block method definitions
  • Fixed a bug where HierarchicalValueExpressions representing virtual interface accesses did not have a valid source range (thanks to @Lauriethefish)
  • Fixed a bug that disallowed non-blocking assignments to ref static variables (thanks to @x-Aksara-x)
  • Fixed a spurious error issued when waiting on a clocking block event and using the iff operator
  • Fixed a bug where calling void-returning system functions during constant evaluation would skip further constant evaluation in that function
  • Fixed a spurious error when ignoring duplicate definitions (with -Wno-duplicate-definition) that are detected and instantiated as valid top modules
  • Fixed a bug where super.new() calls were not allowed as the first item in a sequential block within a class constructor (thanks to @mampcs)
  • Fixed a bug where lvalue concatenation assignments would lose their signedness flag in constant evaluation
  • Correctly disallow the integer and time types as DPI return types
  • Function AST nodes no longer create a return value variable when the function returns void
  • Fixed a bug that disallowed use of the class this handle in extern method default value expressions
  • Fixed a spurious error with assignment pattern port connections in uninstantiated contexts
  • Fixed a spurious error when assigning interface instances to virtual interface variables in uninstantiated contexts
  • The AST representation of virtual interface accesses has been reworked to correctly indicate their runtime semantics
  • Fixed /* in libmap file paths being treated as block comments (thanks to @mampcs)
  • Fixed a crash when ClassType::getBaseConstructorCall was called on a built-in std class type
  • Fixed a spurious error issued for range selects of single-bit packed arrays
  • Fixed AST JSON serialization with --ast-json-detailed-types to not recursively serialize the same class definition (thanks to @usfkotb)
  • Fixed a bug in type compatibility checking for classes that implement interfaces indirectly via a base class
  • Fixed a bug in type compatibility checking for unbound / uninstantiated instances of generic classes
  • Fixed a bug in enum member overflow checking when the enum base type is signed

Tools & Bindings

pyslang

  • Added FlowAnalysis and LSPUtilities bindings (thanks to @CheeksTheGeek)
  • Added SyntaxFactory bindings (thanks to @CheeksTheGeek)
  • Organized pyslang bindings into submodules (thanks to @CheeksTheGeek)
  • Fixed stub generation for the pyslang bindings (thanks to @ilthraim)
  • Added a new lookup_table parameter to AST and syntax node visitors that allow providing a dict of handlers for much faster visitation callbacks (thanks to @jacbro2021)
  • Fixed a lifetime annotation issue with Driver::createCompilation (thanks to @hankhsu1996)
  • Added bindings for DriverSource and DriverFlags (thanks to @sai-cogni)
  • Exposed the thisVar property in SubroutineSymbol and ClassType bindings (thanks to @CheeksTheGeek)

slang-tidy

  • Added a new LoopBeforeReset check (thanks to @spomata)
  • Fixed the diagnostic issued for the AlwaysFFAssignmentOutsideConditional check (thanks to @spomata)

Don't miss a new slang release

NewReleases is sending notifications on new releases.