Commit Graph

9734 Commits

Author SHA1 Message Date
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
mole99 b0c1eab51e Move textfiles to documentation 2023-06-09 13:30:44 +02:00
mole99 41496040e8 Rename to .txt 2023-06-09 13:29:25 +02:00
mole99 265f585096 Document all targets 2023-06-09 13:28:14 +02:00
Cary R c74048a526
Merge pull request #908 from mole99/sdf-info
Move `SDF INFO`,  `SDF WARNING`, `SDF ERROR` to start of line
2023-06-04 21:13:22 -07:00
Cary R a37181ae95
Merge pull request #924 from aelmahmoudy/fix-typos
Fix typos
2023-06-04 21:12:07 -07:00
Cary R 13166092da
Merge pull request #919 from larsclausen/fix-real-format-arm
Fix formatting real to binary and hex strings on ARM
2023-06-04 21:10:49 -07:00
Cary R 9cb3d53633
Merge pull request #918 from larsclausen/fix-single-element-array-ports
Fix connecting single element array ports
2023-06-04 21:09:04 -07:00
Cary R cd293e17af
Merge pull request #895 from larsclausen/fork-in-final
vvp: Handle `%fork` in `final` procedures
2023-06-04 21:07:48 -07:00
Cary R f22c1a519b
Merge pull request #900 from larsclausen/task-return
Support return in tasks
2023-06-04 21:07:30 -07:00
Lars-Peter Clausen 4ab59dd55e Add regression tests for oob write to function return value
Check that partial and fully out-of-bound writes to a function's return
value are handled correctly. Check this for both 4-state and 2-state
vectors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-04 16:27:24 -07:00
Lars-Peter Clausen 925f5fb608 Fix incorrect assert for partial oob write to function return value
Partial out-of-bounds write to a function's return value will trigger an
assert, even though the operation is valid.

The assert checks that the truncated value has the expected width, but
instead it should check that the non-truncated value has the expected with.

Move the assert before the truncation to fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-04 16:04:16 -07:00