Commit Graph

9577 Commits

Author SHA1 Message Date
Stephen Williams 53854bb064
Merge pull request #842 from larsclausen/class-static-prop-base
Allow access to static properties of base classes
2023-01-06 20:17:31 -08:00
Stephen Williams 09e841eee2
Merge pull request #841 from larsclausen/ps-func-call-error-handling
Improve error handling for package scoped function calls
2023-01-06 20:16:20 -08:00
Martin Whitaker 23e51ef7a8 Fix compilation with -Werror=format-security. 2022-12-31 16:51:28 +00:00
Lars-Peter Clausen c8044bddf0 Add regression test for access to static property of base class
Check that it is possible to access a static property of a base class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 11:17:43 -08:00
Lars-Peter Clausen 8a807695e5 Allow access to static properties of base classes
Classes are allowed to access properties of the base class. This also
includes static properties. Currently when looking up a static property
only those of the class itself are considered. Extend this to also consider
properties of the base classes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 11:17:43 -08:00
Lars-Peter Clausen 5563dc6250 Add regression tests for package scoped function call errors
Check that an error is reported, rather than crashing, when trying to do a
package scoped function call when the function does not exist in the
package or is not a function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 10:54:42 -08:00
Lars-Peter Clausen 43443dd7d1 Improve error handling for package scoped function calls
Currently a package scoped function call will result in an assert if the
function does not exist in the package scope.

For non-package scoped function calls instead a proper error is reported.

Refactor the code to share the same code paths between package scoped and
non-package scoped function calls. This makes sure that errors are reported
in both cases. It also makes the code slightly smaller.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 10:53:16 -08:00
Stephen Williams 0958621ad1
Merge pull request #839 from larsclausen/package-scope-member-sel
Elaborate member selects in the scope where they are used
2022-12-29 10:30:23 -08:00
Lars-Peter Clausen b07a66b8a3 Add regression tests for member selects on package scoped identifiers
Check that indices to package scoped identifiers are evaluated in the scope
where the identifier is accessed and not in the scope where the identifier
is declared.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-28 17:54:59 -08:00
Lars-Peter Clausen 710267e9bb Elaborate member selects in the scope where they are used
There are a few cases where a member select on a package scoped identifier
is evaluated in the scope of the package rather than the scope where the
identifier is referenced.

This leads to incorrect behavior if a local symbol is used as an index in a
part select of the referenced member select. E.g.

```
package P;
  localparam N = 1;
  struct packed {
    logic [3:0] x;
  } s = 4'b0101;
endpackage

module test;
  localparam N = 2;
  initial $display(P::s.x[N]); // Will print 0, should print 1
endmodule
```

Use the scope where the member select is used, rather than the scope where
the identifier is defined, to fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-28 17:54:48 -08:00
Stephen Williams a582f66089
Merge pull request #838 from larsclausen/ps-func-call-fix-width
Fix width and sign determination for package scoped function calls
2022-12-28 17:38:35 -08:00
Stephen Williams 1b6e35d6e1
Merge pull request #837 from larsclausen/ivtest-fix-parameter-no-default-result
regress-sv: Fix expected result for parameter_no_default test
2022-12-28 17:35:57 -08:00
Cary R dc8b7d0184 Cleanup some cppcheck warnings 2022-12-28 00:00:31 -08:00
Lars-Peter Clausen 7df00d3070 Add additional regression for package scoped function calls
Check that width and sign determination works correctly for package scoped
function calls.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 20:01:29 -08:00
Lars-Peter Clausen 5634dc6915 Fix width and sign determination for package scoped function calls
`PECallFunction::test_width()` does not consider the package scope and will
not return any information for package scoped function calls.

As a result in contexts where the width or sign of a expression must be
known produces the wrong result when using a package scoped function.

Make sure to search for the function name in the package scope if a package
is specified.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 19:59:10 -08:00
Lars-Peter Clausen 50d7d66043 tgt-vlog95: Handle signed return types
The vlog95 backend currently ignores the sign of a function return value.

Check for it and if `-pallowsigned=1` was specified emit the `signed`
keyword. Otherwise report an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 19:54:44 -08:00
Lars-Peter Clausen 74eaaa7f10 regress-sv: Fix expected result for parameter_no_default test
The parameter_no_default test is expected to pass in SystemVerilog mode.
Make sure the expected result is correctly annotated in the results file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 19:10:43 -08:00
Cary R 5cd8bb3a88 Merge branch 'master' of github.com:steveicarus/iverilog 2022-12-27 16:30:42 -08:00
Cary R 18f8e00f9f Cleanup the force SystemVerilog tests 2022-12-27 16:29:08 -08:00
Stephen Williams 59df5f7d01
Merge pull request #836 from larsclausen/struct-packed-init
Report error for packed struct default member values
2022-12-27 13:57:30 -08:00
Stephen Williams 7c866b2590
Merge pull request #833 from larsclausen/ivlpp-multiline-comment
ivlpp: Improve handling of comments in macros
2022-12-27 13:56:33 -08:00
Stephen Williams 4ce8fa255a
Merge pull request #831 from larsclausen/void-func-always-comb
Let void functions in always_comb block contribute to sensitivity list
2022-12-27 13:52:27 -08:00
Stephen Williams 48bc316f1d
Merge pull request #830 from larsclausen/negative-size-cast
Report an error for size casts with a negative value
2022-12-27 13:45:57 -08:00
Cary R 8a0f395c76 Cleanup the vlog95 results 2022-12-27 12:54:29 -08:00
Cary R f5865f33f6 Update to latest FST files 2022-12-27 11:42:07 -08:00
Lars-Peter Clausen e83c0211b2 Add regression test for default member values in packed structs
Default member values are not allowed in packed structs. Check that an
error is reported for them.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 09:02:36 -08:00
Lars-Peter Clausen 6713b343cc Report error for packed struct default member values
SystemVerilog allows struct members to have default values specified as
part of the struct declaration. But this is only allowed for unpacked
structs. For packed structs an error should be reported. This is defined in
section 7.2.2 ("Assigning to structures") of the LRM (1800-2017).

Currently default member values are just silently discarded if specified
for a packed struct. Make sure to report an error instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 08:46:53 -08:00
Stephen Williams 7d57acc106
Merge pull request #834 from steveicarus/steveicarus/document-ivtests-vxx-list
ivtest: Document the ivest/regress-vNN.list file.
2022-12-26 17:43:02 -08:00
Stephen Williams a7c5eceeea ivtest: Document the ivest/regress-vNN.list file.
This is another bit that needs to be accounted for when changing versions.
2022-12-26 20:10:56 -05:00
Lars-Peter Clausen 8187bf58f7 Add regression test for macros with multi-line comments
Check that multi-line comments are supported in macros.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen 109b794253 Add regression tests for comments in macros
Add regression tests for some corner cases for handling comments in macros.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen c4daf11fac ivlpp: Handle multi-line comments in macros
Make sure that comments spanning multiple lines are supported in multi-line
macros. Since the lexer parses line by line we need a flag to track whether
a multi-line comment is currently active.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen d12a74beec ivlpp: Handle '*' or '/' following C-style comment in macro
A '*' or '/' directly following a C-style comment in a macro currently
triggers the detection of the start of another comment. Fix this by first
looking for a '/' that should start the comment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:28 -08:00
Lars-Peter Clausen 9a96ba62e4 Add regression test for using void function in always_comb block
Check that variables used in void functions contribute to the sensitivity
list in a always_comb block.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:03 -08:00
Lars-Peter Clausen a659ca09ce Let void functions in always_comb block contribute to sensitivity list
Internally void function calls are modeled as task calls. But unlike task
calls, access to a signal inside a void function is supposed to contribute
to the sensitivity list of an always_comb block.

Make sure that the same logic applied for non-void functions is also
applied for void functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:03 -08:00
Lars-Peter Clausen 5685eac1be Add regression tests for invalid size casts
Check that an error is reported for size casts with either a value of 0, a
negative value or an undefined value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:07:22 -08:00
Lars-Peter Clausen 4436dc41ab Report an error for size casts with a negative value
Size casts are only allowed if the value is positive. For cases where it is
0 negative or undefined an error should be reported. Currently the negative
case is not handled. Extend the test to also check for negative values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:07:22 -08:00
Stephen Williams e088bee091
Merge pull request #832 from larsclausen/fix-windows-ci
ci: Windows: Add gperf to dependency list
2022-12-26 16:02:03 -08:00
Lars-Peter Clausen 8b0ace3726 ci: Windows: Add gperf to dependency list
msys2 removed the gperf package from the base-devel package collection[1].

Add gperf explicitly to the dependency list, without this the Windows
CI will fail.

[1] 085698dce3

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 15:07:34 -08:00
Lars-Peter Clausen 13ba780fe8 ci: Windows: Replace `MINGW_INSTALLS` with `MINGW_ARCH`
Currently the Windows build generates a warning

   => WARNING: MINGW_INSTALLS is deprecated, use MINGW_ARCH instead

Make this change to the CI workflow file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 15:07:34 -08:00
Lars-Peter Clausen 42212cfb58 Add `regress-v13.list`
With the development version bumped to v13 the regression tests runner
expects a `regress-v13.list`. Provide one, which is just a copy of the
`regress-v12.list` for now.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 15:07:34 -08:00
Stephen Williams 43c85529af devel: Fix ci build vvp test
The vvp test expects a proper version stamp in the examples/hello.vvp file.
2022-12-26 17:16:26 -05:00
Stephen Williams 8a290830df devel: Step devel past v12 to v13 2022-12-26 12:56:19 -05:00
Stephen Williams 5347ba19cf
Merge pull request #829 from larsclausen/class-super
Add support for handling `super` keyword
2022-12-26 08:33:56 -08:00
Lars-Peter Clausen 295b65da2c Add regression tests for using `super` to access the base class
Check that it is possible to use the `super` keyword to access properties
and methods of the base class that exist with the same name in current
class.

Also check that `this.super` is supported as an alternative to `super` and
has the same behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen 15fa24a664 Add support for `this.super`
SystemVerilog allows to use either `super` or `this.super` to access the
base class. Both have the same behavior. Currently only `super` is
supported, also add support for `this.super`.

To support it the parser has to be changed slightly and move the trailing
`.` after the `this` or `super` keywords into the `implicit_class_handle`
parser rule. This is necessary to avoid reduce conflicts in the grammar.

As a side effect `super` can no longer be used as a standalone identifier.
E.g. `return super;` But that's not legal SystemVerilog anyway, so that is
OK.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen c0adbd0deb Add support for handling `super` keyword
SystemVerilog allows to use the `super` keyword to access properties and
methods of a base class. This is useful if there is for example an
identifier with the same name in the current class as in the base class and
the code wants to access the base class identifier.

To support this a bit of refactoring is required. Currently properties are
internally referenced by name, this does not work if there are multiple
properties of the same. Instead reference properties always by index.

In addition when looking up an identifier that resolves to an object return
both the type and the object itself. This is necessary since both `this`
and `super` resolve to the same object, but each with a different type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen 7188f7b210 Pretty print THIS_TOKEN and SUPER_TOKEN
Internally the special THIS_TOKEN("@") and SUPER_TOKEN("#") are used
to represent the special `this` and `super` keywords in a component
name.

When printing an identifier replace the tokens with their keywords.
This generates nicer error and debug messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen 862b118098 PEIdent::elaborate_{expr,lval}(): Use new symbol_search()
The PEIdent elaborate_expr() and elaborate_lval() are sort of open-coding
the path traversal implemented by the new symbol_search() using the old
symbol_search().

Switch them over to use the new symbol search as it is better at handling
the corner cases and is also less code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:12 -08:00
Stephen Williams cc2ba4f8cb
Merge pull request #825 from larsclausen/typed-constructor
Add support for typed constructor calls
2022-12-24 17:36:01 -08:00