Commit Graph

10116 Commits

Author SHA1 Message Date
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
Stephen Williams 7b1fad78c3
Merge pull request #824 from larsclausen/class-lifetime
Fix variable initialization in class methods
2022-12-24 17:33:29 -08:00
Stephen Williams 507d8cc8ab
Merge pull request #826 from steveicarus/parser-cleanup
Parser cleanup
2022-12-24 17:31:17 -08:00
Martin Whitaker 0271602260 Use consistent format for compiler lexor warning messages.
Capitalise the first word of the main message unless it's a Verilog
keyword. Use VLwarn() in preference to yywarn or direct output to cerr.
2022-12-22 11:03:11 +00:00
Martin Whitaker 6b04d9795a Use consistent capitalisation for compiler parser warning messages. 2022-12-22 10:47:45 +00:00
Martin Whitaker 82aedbc36c Don't automatically add the "warning: " prefix in VLwarn().
One variant did, the other variant didn't. As well as being a trap for
the unwary, this gets in the way of using yywarn/VLwarn for non-fatal
"sorry" messages.
2022-12-22 10:34:56 +00:00
Martin Whitaker bb867480fc Use consistent name for all variant implementations of VLwarn().
The function prototypes both use the name VLwarn, with a macro definition
providing the alias to yywarn. But one of the variant implementations was
named yywarn. Make it consistent with the function prototype.
2022-12-22 10:21:25 +00:00
Martin Whitaker 3335138d16 Remove prototype for unimplemented variant of VLerror(). 2022-12-22 10:18:54 +00:00
Martin Whitaker 2e27b4393d Use consistent format for compiler lexor error messages.
Always prefix with "error: ". Capitalise the first word of the main
message unless it's a Verilog keyword. Use VLerror() in preference
to direct output to cerr.
2022-12-22 10:15:09 +00:00
Martin Whitaker a56ccabf7f Use consistent format for compiler parser error messages.
Always prefix with "error: " or "sorry: ". Capitalise the first word
of the main message unless it's a Verilog keyword.
2022-12-22 10:13:26 +00:00
Lars-Peter Clausen 6334839406 Add regression tests for typed constructor calls
Check that typed constructors calls are supported. Also check various
invalid usages of typed constructor calls and check that an error is
reported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 20:08:58 -08:00
Lars-Peter Clausen df82410a37 Add support for typed constructor calls
By default when creating a new class object the type of the object is
determined by the type of the target.

SystemVerilog also allows to explicitly specify the type of the object to
be created. The specified class still needs to be assignment compatible
with the target. This is e.g. useful to construct an object of a derived
class of the target. E.g.

```
class B; ... endclass
class C extends B; ... endclass
B b;
b = C::new;
```

Add support for this to the parser as well as handling it during
elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 20:03:33 -08:00