Commit Graph

9745 Commits

Author SHA1 Message Date
Lars-Peter Clausen 2a17b06fc4 Add regression test for bit select on multi-dimensional signed packed array
Check that element and bit select on multi-dimensional signed packed arrays
are unsigned.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-26 06:27:52 -07:00
Lars-Peter Clausen 61381fd9cd Fix bit select on signed multi-dimensional packed array
Bit selects on packed arrays are always unsigned and have a width of 1.
Element selects on a multi-dimensional packed array are always unsigned and
have the width of the element.

At the moment a element or bit select on the last level element of a
multi-dimensional signed array will incorrectly yield a signed expression.

Commit 40b36337e2 ("Fix some bugs with packed array dimensions") added
some special checks to fix the width on multi-dimensional array element
selects. But this removed the unsigned attribute from bit selects.

Commit 81947edaa5 ("A bit select is not the same as selecting part of a
packed array") fixed this for single dimensional packed array, but left it
broken for multi-dimensional arrays.

Commit 7c024d6cab ("Fix width calculation for bit/part selects of
multi-dimensioned packed arrays.") added some additional fixes for the
width calculation, which make the special checks in the first commit
unnecessary.

We can now remove those checks which will give us the correct behavior in
terms of the signedness of bit and element selects on both single- and
multi-dimensional packed arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-26 06:27:30 -07:00
Cary R bb39325fe9
Merge pull request #957 from larsclausen/module-array-initializer
Support initializer expression for unpacked array port declarations
2023-06-19 10:56:40 -07:00
Lars-Peter Clausen 79fc09717e Add regression test for module array port initializers
Check that initializers are supported for module array ports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-19 08:08:41 -07:00
Lars-Peter Clausen 3576ba5faa Support initializer expression for unpacked array port declarations
At the moment there are two rules for port declarations. One that allows
the port to be declared as an unpacked array, the other that allows to
specify an initializer expression.

SystemVerilog allows both to be specified in the same port declaration. Add
support for this to the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-19 08:08:41 -07:00
Lars-Peter Clausen 1ee189630b Fix module_output_port_list_def test
The module_output_port_list_def declares a output port with an implicit
data type and assigns an initial value to it. Since output ports with an
implicit data type are nets this test is not standard compliant.

This only works because at the moment the parser incorrectly flags all
output ports with an initial value as variables rather than following the
method defined by the standard to decide whether the port should be a net
or variable.

Make the test standard compliant by using an explicit data type for the
output port, in which case it will be a variable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-19 05:25:02 -07:00
Cary R ffbcb30127
Merge pull request #954 from larsclausen/ci_checkout_v3
ci: Switch to checkout@v3
2023-06-19 00:42:21 -07:00
Cary R df8ac73bba
Merge pull request #953 from larsclausen/assign-pattern-uarray
Add initial support for array assignment patterns
2023-06-19 00:41:33 -07:00
Lars-Peter Clausen 766653bc27 ci: Switch to checkout@v3
The currently used checkout@v2 CI action shows the following deprecation
warning

```
Node.js 12 actions are deprecated. Please update the following actions to
use Node.js 16: actions/checkout@v2. For more information see:
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
```

Github has announced that this will eventually stop working somewhen in mid
2023.

Switch to checkout@v3 which uses Node.js 16 to avoid the ci from breaking
in the near future.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 12:53:58 -07:00
Lars-Peter Clausen 6991b2d84f Add regression tests for assigning scalar value to array
Check that trying to assign a scalar value to an array results in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 12:03:20 -07:00
Lars-Peter Clausen 90a1168086 Add regression tests for unpacked array assignment patterns
Check that basic assignment patterns are supported for unpacked arrays.
Check that all of packed types, reals and string arrays are supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 12:03:20 -07:00
Lars-Peter Clausen 9549156226 Add initial support for array assignment patterns
SystemVerilog allows to use assignment patterns to assign values to an
array. E.g. `int a[4] = '{1, 2, 3, 4}`.

Each value is evaluated in the context of the element type of the array.

Nested assignment patterns are supported. E.g. `int a[2][2] = '{'{1, 2},
'{1, 2}};`

Add initial support for array assignment patterns for both continuous as
well as procedural assignments.

For continuous assignments the assignment pattern is synthesized into an
array of nets. Each pin is connected to one of the assignment pattern
values and then the whole net array is connected to target array.

For procedural assignments it is unrolled in the vvp backend. E.g
effectively turning `a = '{1, 2};` into `a[0] = 1; a[1] = 2;`.

Not yet supported are indexed initializers or `default`.
E.g. `int a[10] = '{1:10, default: 20};`

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 11:50:23 -07:00
Lars-Peter Clausen 4defb9f51e Provide type for array signals
Types for array signals are currently handled as a special case. The type
that is associated with the signal is not the array type itself but rather
the element type.

There is a fair amount of existing code that depends on this behavior so it
is not trivial to change this.

But there are certain constructs such as assignment patterns or array
concatenation where the array type itself is required.

Add a new `NetNet::array_type()` method that will return the array type if
the signal is an array. This will allow to query the array type when
needed.

`NetAssign_::net_type()` is updated to use this new method to return the
array type if the assigned signal is an array.

Long term the special handling of arrays for signals should be removed.
This will for example allow to unify the handling of arrays for signals,
class properties and struct members.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 11:48:54 -07:00
Lars-Peter Clausen bc3cb04a41 Set correct type for indexed array properties
For indexed array properties the type of the expression is the type of the
element.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 11:43:05 -07:00
Cary R 44bc9cba03
Merge pull request #952 from larsclausen/2state-arith
Make result of binary operations 2-state if inputs are 2-state
2023-06-17 07:15:43 -07:00
Cary R a43e7e85b9
Merge pull request #951 from larsclausen/ivl_assert
Replace assert() with ivl_assert() where line information is available
2023-06-16 10:24:04 -07:00
Lars-Peter Clausen 17229f99c9 Make result of binary operations 2-state if inputs are 2-state
The are many binary operations where if the two operands are 2-state the
result is guaranteed to be 2-state.

This is true for all arithmetic operation with the exception of division
where division by 0 will always result in 'x even if the inputs are both
2-state.

The same is true for all binary bitwise operators as well as the binary
logical operators.

Having the expression type be 2-state avoids some unnecessary %cast2
instructions that would otherwise get inserted when assigning the result to
a 2-state variable.

E.g without this change the following will result in

```
  int a, b, c;
  b = a + b;
```

will result in

```
  %load/vec4 ...;
  %load/vec4 ...;
  %add;
  %cast2;
  %store/vec4 ...;
```

For binary comparison operators this is already handled.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-16 07:33:20 -07:00
Lars-Peter Clausen 872ccd32c4 tgt-vvp: Add resize for string element assignment where necessary
There are some cases where during an assignment the elaboration step can
generate constructs with the right-hand-side expression being wider than
the left-hand-side expression.

To handle this the tgt-vvp backend inserts a %pad operation when necessary.
One place where this is missing is when writing to an string element. Here
instead an assert is triggered requiring the right-hand-side expression to
be 8 bits wide.

E.g.
```
bit [7:0] x;
bit [8:0] y;
string s;

x = y; // tgt-vvp inserts %pad
s[0] = y; // tgt-vvp triggers assert
```

Long term this should be fixed at the elaboration stage and insert the
proper width cast. But for now solve this the same way as other places in
tgt-vvp and insert the %pad operation for string element assignments if the
width does not match.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-16 07:29:16 -07:00
Lars-Peter Clausen 3fc6ab5afc Replace assert() with ivl_assert() where line information is available
`ivl_assert()` is similar to `assert()` except that it will also include
source file and line information about the expression for which the assert
was triggered.

Use `ivl_assert()` instead of `assert()` where the line information is
available. This will generate better bug reports and make it easier to
diagnose why an assert is triggered.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-16 05:06:15 -07:00
Cary R 9dd99806ad
Merge pull request #948 from mole99/fix-crash-wildcard
SDF: Implement warning for wildcard cell instanciation
2023-06-15 08:01:49 -07:00
Cary R a815d0fecd
Merge pull request #944 from mole99/timingcheck-warning
SDF: Add TIMINGCHECK warning
2023-06-15 08:01:36 -07:00
mole99 34dc10d798 SDF: Implement warning for wildcard cell instanciation 2023-06-15 10:35:05 +02:00
mole99 340e6fa020 Update gold file 2023-06-15 10:06:03 +02:00
mole99 f1ca97f78f SDF: Add TIMINGCHECK warning 2023-06-15 09:19:18 +02:00
Cary R 560fbeeae4
Merge pull request #936 from larsclausen/trailing-module-port
Allow to omit trailing module ports in ordered list connection
2023-06-14 07:35:39 -07:00
Cary R 0643a3a1f0
Merge pull request #942 from larsclausen/implicit-named-port-connections
Fix line location and require SystemVerilog mode for implicit named port connections
2023-06-14 07:16:28 -07:00
Lars-Peter Clausen 9357a62dce Add regression test for implicit named port connection errors
Check that the file and line location is correct for errors
related to implicit named port connections.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-14 04:33:41 -07:00
Lars-Peter Clausen cc74c7f332 vvp_reg.py: Add support for gold files for CE tests
Some tests require a specific compiler error, rather than just failing. Add
support for this by allowing to check for gold files for CE tests.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-14 04:33:41 -07:00
Lars-Peter Clausen ee4476fed2 parser: Require SystemVerilog for implicit named port connections
Implicit named port connections are only supported by SystemVerilog. Add a
check to generate an error when trying to use it in Verilog mode.

Regression test br_gh315 is modified to run in SystemVerilog mode since it
makes use of implicit named port connections.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-14 04:33:10 -07:00
Lars-Peter Clausen d040804036 parser: Fix line location for implicit named port connections
The implicitly generated identifier for implicit named port connections
gets its file and line information from the optional attributes. If no
attribute list is specified this will just point to the beginning of the
file resulting in incorrect line information.

Use the file and line information from the identifier token instead to fix
this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-13 19:28:53 -07:00
Cary R 75cd1a19f0
Merge pull request #938 from larsclausen/unit-scope-possible-imports
Handle implicit task/function imports in the unit scope
2023-06-11 10:07:29 -07:00
Cary R 3780cb2da2
Merge pull request #937 from larsclausen/continue-break-const-func
Support continue/break in constant functions
2023-06-11 09:38:31 -07:00
Lars-Peter Clausen 542d80b1b1 Add regression tests for implicit function/task import the unit scope
Check that implicit import of functions and tasks is supported if the
wildcard import statement is in the unit scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 09:21:00 -07:00
Lars-Peter Clausen c1c4c28313 Handle implicit task/function imports in the unit scope
SystemVerilog requires that functions and tasks are not implicitly imported
if a symbol with the same name appears in the scope, even if it the symbol
is declared after its usage.

To support this a list of potential imports is collected while parsing a
scope and only when the end of the scope is reached it is evaluated whether
the symbol should be imported or not based on whether it already exists in
the scope.

This currently works fine for all scopes except for the unit scope. Since
the unit scope might span multiple files it is never explicitly closed and
the potential imports are never checked.

Make sure that after parsing all files is done the potential imports for
the unit scope are checked.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 09:20:51 -07:00
Lars-Peter Clausen 946ded13c7 Add regression tests for continue/break in constant functions
Check that continue and break are supported in constant functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:56:06 -07:00
Lars-Peter Clausen ea3884fa1e Support continue/break in constant functions
Add support for `continue` and `break` in constant functions. This is done
in a similar way to how `disable` is implemented for constant functions.

Two new global flags are introduced `loop_break` and `loop_continue` that
get set when evaluating the corresponding statement. If either of these
flags are set all other statements are ignored until the end of a loop is
reached. At the end of the loop both `loop_break` and `loop_continue` get
cleared. If `loop_break` was set before clearing it the loop is exited.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:50:30 -07:00
Lars-Peter Clausen 37f7308f80 Add regression test for omitting trailing ports in ordered list connection
Check that it is possible to omit trailing ports in a module ordered list
connection list.

Also check that an error is generated if too many ports are specified in a
ordered list connection.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:45:34 -07:00
Lars-Peter Clausen b8eb21b3ac Allow to omit trailing module ports in ordered list connection
The current implementation expects that for a module instantiation with a
ordered list connection all ports are supplied.

But there doesn't seem to be such a requirement in the LRMs. The Verilog
LRM doesn't mention anything in this regard and the SystemVerilog LRM
mentions in section 23.3.2.1 that a blank or omitted port connection is
either left unconnected or uses the default value of the port.

Update the implementation so that it allows to omit trailing ports and only
generates an error message if too many ports are specified in the ordered
port list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:45:34 -07:00
Cary R edaa6e6c76
Merge pull request #935 from larsclausen/do-while-continue-break
Handle continue/break in do-while loops
2023-06-11 07:59:01 -07:00
Lars-Peter Clausen 438e510764 Update regression tests for continue/break to cover do-while loops
Also check do-while loops in the regression tests for continue and break
statements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 07:20:15 -07:00
Lars-Peter Clausen fb403c6266 tgt-vvp: Handle continue/break in do-while loops
Currently continue and break are supported in most loops. But not in
do-while loops. Add support for them in do-while loops as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 07:20:15 -07:00
Cary R 750ec01352 Update vlog95 immediate assert/assume gold files 2023-06-10 21:19:32 -07:00
Cary R 63bcb9601d
Merge pull request #906 from svenka3/svenka3/labelled_imm_sva
Added support for labels in immediate assert/assume
2023-06-10 20:59:41 -07:00
Cary R ee14cb0eb0 Update displayed Copyright dates 2023-06-10 20:33:08 -07:00
Cary R ed691d25f7 Add wget commands to update config.guess and config.sub 2023-06-10 20:32:50 -07:00
Cary R 6307057e8d Fix space issues 2023-06-10 19:44:10 -07:00
Cary R bff91566ab
Merge pull request #930 from larsclausen/fix-fn-partial-oob-write
Fix incorrect assert for partial oob write to function return value
2023-06-10 18:00:06 -07:00
Cary R bfba4bf6ca
Merge pull request #932 from mole99/overhaul-documentation
[WIP] Documentation Overhaul
2023-06-10 17:54:33 -07:00
Cary R 5bf44cc78d
Merge pull request #904 from a1ca7raz/master
Update config.guess and config.sub to add support for riscv64 platform
2023-06-10 17:54:11 -07:00
mole99 f4345e2d03 Add favicon 2023-06-09 14:07:28 +02:00