Commit Graph

209 Commits

Author SHA1 Message Date
Lars-Peter Clausen 58ac6ed1f8 Add regression tests for invalid class new
Check that using a class new operator on a variable that is not of a class
type results in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-30 21:13:59 +02:00
Stephen Williams 7e67b8b11b Add br_gh699 regression test. 2022-04-23 18:52:35 -07:00
Stephen Williams 4679c722e3
Merge pull request #698 from larsclausen/type-cast-elaborated
PECastType: Use elaborated data type
2022-04-23 17:33:40 -07:00
Lars-Peter Clausen da21c62f29 Add regression tests for type casts with type identifiers
Check that type casts using type identifiers works as expected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-22 09:06:31 +02:00
Lars-Peter Clausen 9d37878aa7 Add regression test for shortreal module ports
Check that module ports can have the shortreal data type.

Note that SystemVerilog does not allow nets to be of shortreal type.
Supporting net ports with a shortreal type is a Icarus extension.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-21 10:18:12 +02:00
Lars-Peter Clausen 818dfa55f3 Add regression tests for nested dynamic arrays and queues
SystemVerilog allows to declare signals of nested unpacked types. E.g. a
queue of dynamic arrays.

This is currently not supported by Icarus. Add regression test nevertheless
to check that this is reported as a non-supported construct and does not
result in random crashes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 09:58:02 +02:00
Lars-Peter Clausen f42ab248a4 Add regression test for functions with bounded queue return type
Check that the maximum size of a bounded queue is properly handled when
being used as the return type for a function.

Elements beyond the maximum size should be ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 09:58:02 +02:00
Lars-Peter Clausen 724d7d4282 Consolidate unpacked array type elaboration
There are currently two implementations for elaborating unpacked array
types. One that is used when elaborating a signal with an unpacked array
type and one that is used everywhere else using the elaborate_type()
infrastructure.

The elaborate_type() implementation is less complete and for example does
not support bounded queue types.

Consolidate both into a single implementation to reduce duplicated code and
get consistent behavior. This for example makes sure that the maximum queue
size is respected when used as a function return type.

Nested data structures of arrays, dynamic arrays or queues are not yet
supported. In the current implementation when encountering such a type an
assert will be triggered and the application crashes. In the new
implementation an error message will be printed without crashing the
application.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 09:58:02 +02:00
Stephen Williams bf521c7eec
Merge pull request #686 from larsclausen/assignment-pattern-expr
Elaborate array assignment pattern values in the right context
2022-04-17 18:36:18 -07:00
Lars-Peter Clausen a3c329ae84 Add regression tests for evaluating expression within assignment patterns
Check that expressions within assignment patterns are evaluated as if they
were assigned to a variable with the same type as the base type of the
assignment pattern target.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:58:19 +02:00
Lars-Peter Clausen 393c7a3b49 Add a regression test for functions with queue return type
Check that a queue type is supported for the return type of a function.
Make sure that the queue is not cleared in between invocations for
non-automatic functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +02:00
Lars-Peter Clausen 031fbac5be Add regression tests for signed class properties
Check that the signedness of class properties is handled correctly
  * When sign extending
  * When passing as a value to a system function

Check this for both when accessing the property from within a class method
as well as accessing it on a class object.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 12:01:23 +02:00
Lars-Peter Clausen 0c123b8498 Add regression tests for methods with signed return values
Check that the signedness of the return value of methods is handled
correctly.
  * When sign extending
  * When passing as a value to a system function

Check this for both methods on user defined class as well as built-in
methods on SystemVerilog types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 12:01:23 +02:00
Stephen Williams 752a28598b
Merge pull request #681 from larsclausen/signal-real-type
Use `real_type_t` as the data type for `real` type signals
2022-04-13 22:23:14 -07:00
Stephen Williams 760ecfc44f
Merge pull request #680 from larsclausen/class-static-prop-assign
Handle assignment to static class properties in class methods
2022-04-13 22:20:55 -07:00
Lars-Peter Clausen 4ae2eec275 Add regression test for Verilog AMS abs() with function call argument
Check that the behavior of the Verilog AMS `abs()` function is correct when
its argument is a function call. Check this for both vector as well as real
types.

This test is largely a copy of the existing vams_abs2 test, just replacing
the identifier argument with a function call argument.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 19:38:34 +02:00
Martin Whitaker 6b5d7a3695 Add regression test for br_gh672. 2022-04-12 16:59:41 +01:00
Lars-Peter Clausen ea55421a07 Add regression test for accessing static class properties
Check that static class properties can be accessed for read and write and
that they are shared between all instances of a class type.

Check that this works for the following 3 cases

 * accessing the static property in a class function or task
 * accessing the static property in a class function or task using `this`
 * accessing the static property on a class object instance

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 11:45:30 +02:00
Lars-Peter Clausen 338516bc55 Add regression tests for constant recursive functions
Check that constant recursive functions are supported. Check both Verilog
style using assignments to the implicit function return signal and
SystemVerilog style using `return`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-11 22:03:02 +02:00
Lars-Peter Clausen 5b6d8e968d Add regression test for recursive function using `return
Add a regression test that checks that recursive functions using a `return`
statement work correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-11 22:03:02 +02:00
Stephen Williams 7c5694e516
Merge pull request #673 from larsclausen/package-no-implicit-var
Require explicit data type for package variable declarations
2022-04-10 15:06:26 -07:00
Stephen Williams 3da5b4cf65
Merge pull request #664 from larsclausen/integer-port
Correctly handle separate port type declaration for integer types
2022-04-10 15:05:48 -07:00
Stephen Williams 070b8af63c
Merge pull request #663 from larsclausen/class-constructor
Small class syntax improvements
2022-04-10 14:56:51 -07:00
Stephen Williams 99eaf007a1
Merge pull request #662 from larsclausen/array-base-type-scope
Elaborate base type of array types in the right scope
2022-04-10 14:56:07 -07:00
Martin Whitaker 50ae8cf552 Add regression test for br_gh674. 2022-04-10 21:58:39 +01:00
Lars-Peter Clausen 35c69366a5 Add regression tests for implicit variable declarations in packages
Check that it is not possible to declare a variable in a package without an
explicit data type for the variable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-09 09:15:23 +02:00
Martin Whitaker 42de9e646a Add regression test for br_gh661 and test for correct $random behaviour. 2022-04-03 19:56:56 +01:00
Lars-Peter Clausen 4c9af1c47a Add regression tests for non-ANSI integer module ports
Check that it is possible to declare the type separately from the direction
for non-ANSI integer, time and atom2 ports. Check that it is possible to
both declare the type before and after the direction.

For integer, time and atom2 types the range specification on the port
direction declaration should be empty, rather than the implicit packed
dimension of the integer type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:40:25 +02:00
Lars-Peter Clausen 571f222a73 Add additional regression tests for class syntax
Check that it is possible to both declare and call class constructors
without using parenthesis after the `new` keyword.

Check that a non-ANSI port for a class constructor results in an error.

Check that it is possible to invoke a class task through a implicit class
handle (`this` or `super`) without using parenthesis after the task name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:14:56 +02:00
Lars-Peter Clausen 1a95dafc8d Add regression tests array base type elaboration scope
Check that for typedefs of array, dynamic array and queue types the base
type is elaborated in the right scope. There are separate tests for vector
base type and other base types since these take different paths internally.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 09:17:24 +02:00
Stephen Williams d480c4d7d0
Merge pull request #659 from larsclausen/typedef-overwrite
Support typedef overwrites with unpacked dimensions and in classes
2022-03-27 15:49:55 -07:00
Stephen Williams 658d4f5eee
Merge pull request #658 from larsclausen/class-in-module
Handle multiple instances of modules with class definitions
2022-03-27 15:48:56 -07:00
Stephen Williams 4f971ea4f9
Merge pull request #657 from larsclausen/enum-base-type
Support type identifier base type for enum
2022-03-27 15:47:34 -07:00
Martin Whitaker 8a19380a5d Add multi-file VPI test. 2022-03-26 16:44:57 +00:00
Lars-Peter Clausen 315bc1908a Add regression tests for enum base type
Check that the behavior for all sorts of base types for enums is correctly
implemented. Both for valid as well as invalid base types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-25 21:55:34 +01:00
Lars-Peter Clausen 252174d15a Add additional regression tests for typedef overwrites
Check that it is possible to create a typedef of an array type that shadows
an existing typedef in a higher level scope.

Also check that it is possible to create a typedef in a class scope that
shadows an exiting typedef in a higher level scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-23 10:53:56 +01:00
Cary R 86a7707482 Update vlog95 regress for some recent test changes 2022-03-23 00:07:30 -07:00
Lars-Peter Clausen abe5e692ce Add regression test for classes defined in modules
Check that it is possible to have multiple instances of a module
that declares a class and that the class in each module instance
is a unique type that can have dependencies on module parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-22 11:53:47 +01:00
Martin Whitaker 2c505f0040 Add regression test for issue #621. 2022-03-21 19:55:15 +00:00
Stephen Williams fc80465b87
Merge pull request #656 from larsclausen/enum-compatibility
Restrict enum compatibility to the same scope
2022-03-20 19:13:56 -07:00
Stephen Williams f73af99ce7
Merge pull request #655 from larsclausen/fix-udp-output-reg
parser: Fix UDP registered output syntax
2022-03-20 19:12:34 -07:00
Stephen Williams af09d86113
Merge pull request #647 from larsclausen/non-ansi-ports
Allow to declare direction after data type for non-ANSI ports
2022-03-20 19:10:49 -07:00
Lars-Peter Clausen 83da384df3 Add regression test for enum compatibility across module boundaries
Check that the compatibility of signals of enum data type across module
boundaries.

If the enum data type is declared at a higher level scope or imported from
a package the signals are compatible between different module instances. If
the enum data type is declared within the module itself though the signals
are not compatible.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-19 17:17:21 +01:00
Lars-Peter Clausen c5e160f1dd Add regression test for `output reg` syntax for UDPs
Check that it is possible to declare a registered output of a user defined
primitive using the `output reg` syntax.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-19 13:00:04 +01:00
Martin Whitaker e53b2e774b Further fixes for vvp code generation for c. assign of an array word.
The draw_net_input() function can write additional statements to the output
file, so must not be called in the midst of writing a statement.
2022-03-19 10:22:49 +00:00
Lars-Peter Clausen db33dbfbcc Add regression tests for task non-ANSI port declarations
Check that it is possible to define the data type of a non-ANSI task port
in a separate declaration from the port direction. Add tests for both the
type declared before the port direction and for the type declared after the
port direction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 09:17:55 +01:00
Lars-Peter Clausen ee81ac2f85 Add regression tests for module non-ANSI port declarations
Check that it is possible to define the data type of a non-ANSI module port
in a separate declaration from the port direction. Add tests for both the
type declared before the port direction and for the type declared after the
port direction.

Note that this doesn't work yet correctly for integer type module ports
yet, so there are no tests for this. This will be addressed in follow up
work.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 09:17:55 +01:00
Martin Whitaker 831db5a0d7 Fix vvp code generation for c. assign shift of array word (issue #632) 2022-03-14 23:24:20 +00:00
Stephen Williams 15e1a7a3f2
Merge pull request #644 from larsclausen/port-range-mismatch-recover
Recover from port and signal vector range mismatch
2022-03-13 14:36:31 -07:00
Stephen Williams d7e4d209b8
Merge pull request #640 from larsclausen/darray-packed-array
Support dynamic arrays and queues of packed arrays
2022-03-13 14:33:27 -07:00
Lars-Peter Clausen a9c0469b2b Add regression test for task port range mismatch
Check that a range mismatch is detected for non-ANSI task ports when
port direction and data type are declared separately.

An error should be reported and no crash should occur.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-13 11:17:27 +01:00
Lars-Peter Clausen 026d552be1 Add regression test for module port range mismatch
Check that a range mismatch is detected for non-ANSI module ports when port
direction and data type are declared separately.

An error should be reported and no crash should occur.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-13 11:07:10 +01:00
Lars-Peter Clausen 1a10abeae7 Add regression tests for queue of packed arrays
Check that queues of packed arrays are supported. These tests are identical
to the existing queue tests for other data type, just that the data type
is a packed array.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 14:07:06 +01:00
Lars-Peter Clausen babfacee9a Add regression test for dynamic arrays of packed arrays
Check that it is possible to declare a dynamic array of a packed array
type. The test is identical to the tests for the other supported dynamic
array types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 14:07:06 +01:00
Lars-Peter Clausen 5cc825f45d Support dynamic arrays and queues of packed arrays
Currently only dynamic arrays and queues of atom2 and vector types are
supported. Add support for packed arrays. Since these three types are
essentially handled the same internally supporting this only requires to
allow to elaborate a packed array base type.

Factor out type elaboration into a helper function that can be shared
between the elaboration of the base type of a dynamic array or queue and
the type for other signals. This gives consistent behavior and will also
make it easier to support additional base types for dynamic arrays or
queues.

Note that it is not yet possible to index elements of packed array dynamic
arrays or queues. But neither is it possible to do a bit select for vector
or atom2 type dynamic arrays or queues yet. Supporting this needs some
additional work.

There is one test that declares a queue of a struct type, but doesn't use
it since it is not supported. With this change a error will generated when
trying to declare a queue of a struct. So update that test to not declare
the variable so it does not fail.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 14:07:06 +01:00
Lars-Peter Clausen 9fd91a8df8 Add regression test for empty class item
Check that the empty class item is supported by the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-11 21:34:06 +01:00
Stephen Williams ede341410f
Merge pull request #636 from steveicarus/string-special-characters
String special characters
2022-03-05 19:12:16 -08:00
Stephen Williams d2ac403415 Add sv_string7 and sv_stting7b tests.
These test string assignments of various escaped special characters.
2022-03-05 18:49:37 -08:00
Lars-Peter Clausen 41b4ce5f8c Add regression test for part select on vector declared in package
Check that it is possible to do a part select on a vector declared in a
package.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-05 15:29:34 +01:00
Lars-Peter Clausen 8a2d4e4fa4 Add regression test for Verilog data types on module input ports
Using Verilog data types on module input and inout ports is an error in
Verilog. But in SystemVerilog it is allowed and the port should be a net
with the specified data type.

Check that this is supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:49:59 +01:00
Lars-Peter Clausen 2921e66105 Add regression test for invalid net data types
Add regression tests that check that declaring a net of type class, dynamic
array, queue or string result in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:30:28 +01:00
Lars-Peter Clausen 472598dd74 Report errors for nets with invalid data type
While a variable can have any data type the data type for nets is quite
restricted.

The SystemVerilog LRM section 6.7.1 ("Net declarations with built-in net
types") requires that the data type of a wire is either a 4-state packed or
a unpacked struct or unpacked array of 4-state packed types.

As an extension to this iverilog allows real data type for wires as well as
2-state packed types.

Add a check that reports an error if a net with any other type is declared.

In addition in Verilog a net can not have an explicit data type at all. It
can only have a packed dimension and a signed flag. As an extension to this
Icarus also allows wires to be of `real` data type.

Note that in Verilog mode the data type is checked in the parser since only
the parser knows whether the data type is an implicit type (`input reg
[7:0]` and `input [7:0] x` elaborate the same). But for SystemVerilog the
type is checked during elaboration since due to forward typedefs and type
parameters the type is not necessarily known in the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:30:12 +01:00
Stephen Williams fbc91ec7cf Add the sv_strings6 test to check string.itoa et al. 2022-02-27 20:44:23 -08:00
Stephen Williams fa864156e4
Merge pull request #629 from steveicarus/always_comb-vs-void-func
Always comb vs void func
2022-02-27 16:17:53 -08:00
Stephen Williams 035325e9df Regression test for issue 576. 2022-02-27 14:21:22 -08:00
Lars-Peter Clausen f53a95840a Add regression tests for module output variable type ports
Check that a output port that has a explicit data type, but no explicit
net type is elaborated as a variable type port.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-27 13:28:26 +01:00
Stephen Williams 978717f914
Merge pull request #623 from larsclausen/task-ports-sv
Support SystemVerilog non-ansi task/function port declarations
2022-02-26 09:16:33 -08:00
Lars-Peter Clausen 372e3eae25 Add regression test for SystemVerilog task port types
Check that it is possible to declare task ports with SystemVerilog types.
Both ANSI style and one for non-ANSI style.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-25 10:43:28 +01:00
Lars-Peter Clausen 2e845821a8 Add regression test for localparams in classes
Check that localparams and non-overridable parameters can be declared in a
class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:45:22 +01:00
Lars-Peter Clausen 427091d3d3 Support access to class constants on objects
It is allowed to access a constant declared in a class scope, such as a
enum value or parameter, on an object of that class type. This is described
in section 8.5 ("Object properties and object parameter data") of the LRM
(1800-2017).

E.g.

```
class C
  enum { A } e;
endclass

C c = new;
c.e = c.A;
```

Support this by in addition of searching for class properties on the object
also search for constants in the class scope.

A bit of refactoring is needed around the parameter elaboration functions
since they expect a non-const NetScope, but for classes we only have a
const scope available.

The non-const scope is needed to be able to mark specparams as
non-annotatable. Since classes can't have specparams this part is factored
out into a separate function the NetScope parameter for the shared
functions is made const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:45:14 +01:00
Stephen Williams cc0a8c8dd2
Merge pull request #618 from larsclausen/signal-decl-consolidation
Consolidate signal declaration
2022-02-18 08:27:52 -08:00
Stephen Williams afaaaed0a4
Merge pull request #617 from larsclausen/generate-invalid
Generate error for invalid declarations within generate block
2022-02-18 08:26:08 -08:00
Lars-Peter Clausen ce8ee42619 Add regression test for class new initializer
Check that it is possible to use a class new as
an initializer for a variable or property declaration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 11:59:09 +01:00
Lars-Peter Clausen b37636e4fc Add regression test for invalid declarations in generate blocks
Check that the following declarations inside a generate block generate an
error:
 * module, program or interface
 * specparam
 * specify block
 * timeunit

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-16 11:23:39 +01:00
Lars-Peter Clausen bb74c6412d Refactor test for invalid parameter overrides
Split the test into multiple tests that each check one type of invalid
override rather than having one big tests that checks for everything.

This allow to check whether the test passes or fails by seeing if it
compiles or not. The one big test on the other hand relies on seeing the
exact error messages as recorded in the gold file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-15 11:31:35 +01:00
Stephen Williams 6c04749a68 Add the l_impl test for the logical implication operator. 2022-02-13 18:48:40 -08:00
Lars-Peter Clausen 91579c7c79 Add regression tests for parameters without default
SystemVerilog supports parameters without default values in parameter port
list. Add regression tests to check this feature.

Also add a regression test to check that modules without a default
parameter are not automatically picked as a toplevel module.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 18:21:56 +01:00
Stephen Williams b1fb4a6117
Merge pull request #611 from larsclausen/bits-types
Support calling $bits() with built-in data types
2022-02-13 08:15:46 -08:00
Stephen Williams 13aa782be2
Merge pull request #609 from larsclausen/sv-omit-param-keyword
Allow omitting `parameter` in module parameter port list
2022-02-13 08:13:11 -08:00
Lars-Peter Clausen ef42df6fef Add a regression test for calling $bits() with a data type
Check that $bits() can be called with packed data types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 15:03:49 +01:00
Lars-Peter Clausen 481f461e59 Add regression test for expressions in attributes
Check that all types of constant expressions are supported in attributes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-12 17:56:30 +01:00
Lars-Peter Clausen 7f40e120c8 Add regression tests for omitting `parameter` in parameter port list
SystemVerilog allows to completely omit the `parameter` or `localparam`
keyword in the parameter list. Both at the beginning and before redefining
the parameter data type. This is not support in Verilog.

Add regression tests that check that this is supported when in
SystemVerilog mode.

It is not valid to use an implicit data type e.g. just `signed` when
`parameter` was omitted, add regression tests to check for this as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-11 11:09:59 +01:00
Stephen Williams 771d02bee1
Merge pull request #607 from larsclausen/sv-parameter-in-generate
Allow parameter in generate blocks for SystemVerilog
2022-02-10 17:16:22 -08:00
Stephen Williams bb36a16704
Merge pull request #604 from larsclausen/parser-end-label-unnamed
Let the parser recover from end label on unnamed block
2022-02-10 17:14:42 -08:00
Lars-Peter Clausen 47e6c71113 Add regression tests for parameters in generate blocks
In Verilog a parameter in a generate block is invalid and should
result in a compile error.

In SystemVerilog on the other hand it is valid, but it is equivalent
to a localparam and can't be overridden.

Add regression tests that check for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-10 11:37:38 +01:00
Lars-Peter Clausen 42dd8a0703 Add regression test for class with scoped base class type
Check that classes with a scoped base class type get elaborated correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:50:51 +01:00
Lars-Peter Clausen 305a1a9262 Add regression test for end labels on unnamed blocks
An end label on an unnamed block should generate an error. Add a regression
test to check this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:33:36 +01:00
Lars-Peter Clausen 7e18eba848 Add helper function to check end label
Most named constructs support a end label in SystemVerilog. The handling of
this end label is always the same.

 * Generate an error if the end label does not match the name of the block
 * Generate an error if not in SystemVerilog mode
 * Delete the end label

Factor this into a common helper function. This reduces code size a bit and
results in consistent error messages.

The latter requires refreshing of some gold files to match the slightly
different error messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:33:36 +01:00
Lars-Peter Clausen 4a9200f5f2 Add regression test for variable declarations in unnamed forks
SystemVerilog supports variable declarations in unnamed forks, while
Verilog does not.

Add a regression test that checks for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 14:13:17 +01:00
Stephen Williams 687abbd030 Fix localparam_implicit.v test
The localparam_implicit.v test was broken by a recent commit. Fix the
test, since the commit is correct and the test really is broken.
2022-02-01 19:15:01 -08:00
Stephen Williams 6db40d9f14
Merge pull request #599 from larsclausen/parameter-invalid-error
Report error when trying to override non-existing parameter
2022-02-01 17:39:44 -08:00
Lars-Peter Clausen 880f4927bf Add regression test for invalid parameter overrides
Check that invalid parameter overrides generate an error.

There are some cases that are not handled correctly today. The test will be
updated once they are addressed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-01 23:17:47 +01:00
Lars-Peter Clausen 0ab1ed916f Report error when trying to override non-existing parameter
Overriding a parameter that does not exist will only generate a warning at
the moment. This can hide programming mistakes such as an typo in a
parameter override.

There is nothing in the LRMs to support that this should only be warning,
so elevate this to an error. This is consistent with how an error is
generated when trying to reference a non-existing port or variable.

The generated error message differentiates between whether the parameter
does not exist at all, or whether it is a localparam.

There are two regression tests that rely on that only a warning is
generated, these have been updated to expect an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-01 22:50:21 +01:00
Lars-Peter Clausen f25d7a74bc Add regression test for implicit `localparam`
Check that all parameters in a parameter port list after a `localparam` get
elaborated as localparams, until the next `parameter`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-31 10:09:45 +01:00
Lars-Peter Clausen 1c0955178d Add regression test for struct member signedness
Check that when using a struct member in an expression its signedness is
handled correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-27 10:54:41 +01:00
Lars-Peter Clausen fa643cbfe1 Add regression tests for enum and struct line info
Check that when an error message for a enum or struct data type is
generated it points to the location of the declaration of the type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 20:09:05 +01:00
Stephen Williams 32f01f87a6
Merge pull request #594 from larsclausen/block-with-only-var-decl
Allow unnamed begin/end block with only variable declarations
2022-01-23 10:41:48 -08:00
Lars-Peter Clausen 67b29ab5d4 Add a regression test to check enum elaboration order
Test that enums are elaborated in declaration order and a enum declaration
can reference a item of an enum that was declared before it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 19:08:22 +01:00
Lars-Peter Clausen 30b70923b5 Add regression test for variable declarations in unnamed blocks
SystemVerilog supports variable declarations in unnamed blocks, while
Verilog does not.

Add a regression test that checks for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 18:52:35 +01:00
Lars-Peter Clausen 5fc1976496 Add regression test for explicit cast to packed array and packed struct
These test verify that explicit cast to packed array and packed struct
types are supported and executed correctly.

The tests are based on the test for integer casts. Just the type of the
variables was changed to packed array and packed struct respectively.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:29 +01:00
Lars-Peter Clausen 1858c6a313 Set regression test for explicit enum cast to supported
Update the enum cast test to reflect that enum casts are now supported.

Also add a small check to verify that the right value got assigned to the
enum after the cast.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:28 +01:00
Stephen Williams 7c73ef8fb6 ivtest: Mark as NI tests that are known to fail.
Mark them as NI so that in the fugure they might be turned back
on if they can be made to work. Keep the tests around as reference.

Also, remove reports that are no longer tested in CI. This is because
they are no longer tested by a previous patch that relies on the
change vvp_reg.pl behavior around failed tests.

Remove now obsolete update_msys2_report.pl, and simplify the test.sh
script, since diff commands and Windows specific trickery are no
longer needed.
2022-01-16 13:17:46 -08:00
Stephen Williams d0b9c11d35 ivtest: vvp_reg.pl sets exit status
If there are any failures, return a non-zero exit status so that
invoking scripts can detect that failures happen. This eliminates
the need to use regression report reference outputs, and should
make it easier to merge PRs that add or impact tests.
2022-01-16 11:03:21 -08:00
Lars-Peter Clausen e176ce0776 Add regression test for signed struct
Add a test that checks that signing annotations on structs are supported
and that signed structs are properly evaluated as a signed value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-16 16:16:33 +01:00
Lars-Peter Clausen 38c4c20cbc Add test for packed arrays of types from other scopes
Extend the array_packed test to check declaring a packed array of a type
from another scope that is addressed via a scoped identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 22:26:29 +01:00
Lars-Peter Clausen c670170ac0 Add test for direct packed arrays of struct and enums
It is possible to directly declare a packed array of a struct or enum
without having to create a typedef first.

Add a check to the array_packed test that this is supported and works as
expected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 22:26:29 +01:00
Lars-Peter Clausen d856a35e4d Add regression test for enums declared in structs and classes
These tests check that a enum that is declared in a struct or class are
correctly elaborated and also name collisions with the enum names are
detected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 21:43:01 +01:00
Lars-Peter Clausen 3e5f9fd044 Add a regression test with invalid struct member declarations
The test checks that all invalid declarations produce an error and also do
not crash the application.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 19:54:13 +01:00
Stephen Williams cea237b407 Add ivtest to the iverilog source tree
By adding ivtest to the iverilog source tree, it is easier to keep
the regression test synchronized with the source that is being tested.
This should be especially helpful for PRs that add a new feature, and
have a matching ivtest PR with the regression test for that feature.
2022-01-15 10:18:50 -08:00