Commit Graph

246 Commits

Author SHA1 Message Date
Stephen Williams 0ac3997142
Merge pull request #858 from larsclausen/class-prop-shadow
Consolidate class property handling
2023-01-16 11:23:44 -08:00
Stephen Williams 46a11f4b67
Merge pull request #845 from wmlye/wmlye/assertion-issue823
Clean up assertions in #823 and #840
2023-01-16 10:35:00 -08:00
Lars-Peter Clausen 4cc3c7b08f Add regression tests for shadowing class properties
Check that class properties can be shadowed by local symbols in class
methods and also check that a package scoped identifier with the same name
as class property can be accessed in a class method.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 07:13:42 -08:00
Stephen Williams b74059eaa9
Merge pull request #855 from steveicarus/steveicarus/loop-control-support
Add break and continue loop control statements support
2023-01-15 22:21:55 -08:00
Stephen Williams 7b105a696d
Merge pull request #857 from larsclausen/import-hier-fail
Don't allow access to imported identifiers through hierarchical names
2023-01-15 22:18:46 -08:00
Stephen Williams 557bb61d10 ivtest: add br_gh191_break and br_gh191_continue tests 2023-01-15 21:47:52 -08:00
Stephen Williams 6c9c876c83 Add compiler support for break and continue
This includes support at the parser (pform) through enaboration
and the netlist format for the break and continue statements.

Elaboration actually already worked for for-loops, but since the code
generators need more information, this is a rewire of that support to
be explicit about for-loops. This means they are not rewritten as fancy
while loops. The code generators will have to handle that.

Given the elaboration of for-loops now work, write the vvp code generator
support needed to implement it.

Now that for-loops are presented as for-loops to the code generator, the
vlog95 code generator doesn't need to infer them anymore. Generate the code
more directly.

Also update the tests list so that the vlog95_reg tests all pass.
2023-01-15 21:46:20 -08:00
Lars-Peter Clausen 535c09db62 Add regression test for package scoped method call
Check that it is possible to call a method on a package scoped identifier.
Both for built-in types as well as class objects.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-08 07:59:20 -08:00
Lars-Peter Clausen f9a0e2f401 Add regression tests for accessing imported identifiers through hierarchical names
Check that an error is reported when trying to access an imported
identifier through a hierarchical name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-07 10:31:02 -08:00
Stephen Williams 08f2c88fcf
Merge pull request #852 from larsclausen/vvp-string-vpi
vvp: Handle null-bytes in a conistent way when reading through VPI
2023-01-06 20:21:03 -08:00
Stephen Williams 97b897cb38
Merge pull request #851 from larsclausen/str-literal-to-str-remove-null-byte
vvp: Remove null-bytes when converting string literals to SV strings
2023-01-06 20:19:33 -08:00
Stephen Williams 9931d92c70
Merge pull request #843 from larsclausen/ps-array-cassign
Handle continuous array assignments from package scoped indentifiers
2023-01-06 20:18:44 -08:00
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
Lars-Peter Clausen 71bb011597 Add regression tests for string formatting of null-bytes through VPI
Check that null-bytes get removed when reading a value through the VPI API
as a vpiStringVal. Also check that null-bytes are not removed from string
literals when string literals are read through the VPI API as a non
vpiStringVal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 16:22:46 -08:00
Lars-Peter Clausen b8ddeb8848 vvp: Handle null-bytes in the string literal VPI support
The VPI API for string literals does not correctly handle the case where a
null-byte ('\0') appears in the string literal. It uses strlen() to
calculate the length of the literal, which will give the wrong result if
there is a null-byte in the string literal. Instead of using strlen() use
the stored length to fix this.

In addition when formatting a string literal as a string ignore any
null-bytes. The LRM is not entirely clear what should happen to null-bytes
when formatting a value as a string. But the behavior of ignoring the
null-bytes is consistent with the rules of SystemVerilog for converting a
string literal to a SV string.

This problem can occur when a string literal gets null-byte left-padded due
to width of its context of its expression, but then optimization removes
part of the expression and only leaves the padded string literal.

E.g.
```
$display(0 ? "Yes" : "No");
```

will be transformed into

```
$display("\000No");
```

There is also one subtle change in behavior associated with this. The empty
string ("") is supposed to be equivalent to 8'h00. So e.g.
`$display(":%s:", "")` should print ": :" since the width of the empty
string is 1 byte and the %s modifier prints a string with the width of the
value, left-padding with spaces if necessary. The current implementation
will print "::" though. This change requires to update the marco_with_args
gold file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 15:35:34 -08:00
Lars-Peter Clausen 56baae11cc Add regression tests for null-byte handling when assigning to SV strings
Check that when assigning or casting a string literal or vector to a SV
string type that null-bytes are removed.

Also check that writing a null-byte to an element of a string variable is
ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 13:20:11 -08:00
Bill Lye b277f07b3a Typo 2022-12-31 13:39:58 -08:00
Bill Lye 696c5d5d12 Renamed testcases from "*.sv" to "*.v" 2022-12-31 13:37:45 -08:00
Bill Lye 6f1165a628 Added regression tests for issues #823 and #840 2022-12-31 11:57:33 -08:00
Lars-Peter Clausen f42bb35c3e Add regression tests for packed scoped continuous array assign
Check that continuous array assignments from package scoped identifiers are
supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-30 10:35:35 -08: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 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 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
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
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 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
Cary R 8a0f395c76 Cleanup the vlog95 results 2022-12-27 12:54:29 -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 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 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 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 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
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
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 6b04d9795a Use consistent capitalisation for compiler parser warning messages. 2022-12-22 10:47:45 +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 748d6d8de2 Add regression tests for class methods with static lifetime
Check that trying to specify a class method with static lifetime results in
an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 19:28:46 -08:00
Lars-Peter Clausen da4ac3607a Add regression test for var init in class method
Check that variable initialization as part of the declaration works as
expected in class methods.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 19:28:46 -08:00
Stephen Williams 580d79eae3
Merge pull request #820 from larsclausen/array-compatibility
Add error checking for continuous unpacked array assignments
2022-12-21 11:38:15 -08:00
Martin Whitaker cd0b360575 Support free-form `default_net_type directives. 2022-12-20 18:14:18 +00:00
Martin Whitaker 79a3d08d69 Support free-form `begin_keywords and `end_keywords directives. 2022-12-20 18:14:18 +00:00