Commit Graph

10510 Commits

Author SHA1 Message Date
Lars-Peter Clausen e9d3fe4ea3 Consolidate parameter up/down part select
The methods for handling up and down part select are nearly identical
and only differ in a hand full of lines.

Consolidate them into a single method to remove the duplicated code.
This makes it easier to maintain the code and add future changes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:25:16 -07:00
Lars-Peter Clausen 10349287a0 Add regression tests for enum typedefs in nested scopes
Check that enum literals declared by enum typedefs in generate blocks, named
blocks, tasks and functions can be referenced from the same scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:24:53 -07:00
Lars-Peter Clausen 9bc86af284 elab: Elaborate enum types in nested scopes
Enum types declared inside nested scopes are stored separately from typedefs.
The enum sets need to be elaborated when the `NetScope` is created so enum
literals are available for declarations and statements in the same scope.

Module, package and class scopes already do this. Generate, task, function and
named block scopes can also declare enum typedefs, but did not elaborate their
enum sets. Elaborate them while setting up these scopes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:24:53 -07:00
Lars-Peter Clausen 593a97bede vvp: Bound VPI label scanset parsing
The VPI label resolver parses word and string labels into a 32 byte
temporary buffer. The scansets used by sscanf() did not specify a width,
so malformed labels could write past the end of the buffer.

Limit the scansets to the size of the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 13:13:24 -07:00
Lars-Peter Clausen d5a16b31a1 Add regression test for empty old-style UDP table
Check that an empty old-style UDP table reports the parser error and the
invalid primitive error instead of crashing.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 13:13:05 -07:00
Lars-Peter Clausen 20a969bf38 Handle invalid old-style UDP tables
An empty old-style UDP table leaves the parsed table pointer unset after
the parser reports the table error. The old-style UDP creation path still
passed the null pointer to process_udp_table(), which crashes.

Report an invalid UDP table instead and do not register the primitive.
Also keep the new-style invalid-table diagnostic formatting consistent.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 13:13:05 -07:00
Cary R 4b9675abd7 Update unused function in lz4 2026-06-20 08:53:42 -07:00
Cary R 8caa3af689 Update to the latest GTKWave files. 2026-06-20 07:57:16 -07:00
Lars-Peter Clausen de415b2f03 Add regression tests for nested function and final contexts
Check that statements that are not allowed in functions or final procedures
are still rejected when they are placed in a named block scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:34:34 -07:00
Lars-Peter Clausen 5b512e4f1e Preserve function and final context in nested scopes
Currently checks for statements that are not allowed in functions or final
procedures only inspect the immediate scope. If the statement is inside a
named block or a block with declarations, the current scope is the block and
the context is lost.

Make `NetScope::in_func()` and `NetScope::in_final()` preserve the context
through begin-end, fork-join and generate block scopes. Other scope types are
treated as context boundaries so function and final state does not leak across
subroutine or definition scopes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:34:34 -07:00
Lars-Peter Clausen c5c0b09ef6 Add regression tests for queue method argument count errors
Check that queue push_back(), push_front() and insert() report errors when
called with too few or too many arguments.

These tests are expected to fail as compile/elaboration errors. They also make
sure the invalid calls do not crash during elaboration while reporting the
argument count error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:58 -07:00
Lars-Peter Clausen aa3d804b72 Fix out-of-bounds write for missing queue method arguments
When a method argument is missing, the error path stores a nullptr in the
argument vector for that missing slot. The vector was sized from the number of
arguments that were present in the source, so calls such as `q.push_back()` or
`q.insert(0)` wrote those nullptr placeholders past the end of the vector.

Size the vector from the number of arguments required by the queue method
instead. This gives the error path slots for the missing arguments while
leaving valid calls unchanged.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:58 -07:00
Lars-Peter Clausen 2fc9d27190 Add regression test for multi-dimensional packed class properties
Check that multi-dimensional packed vector class properties can be emitted,
assigned, and read back through a class object.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:18 -07:00
Lars-Peter Clausen 1e6e69ee7f Support multi-dimensional packed vectors as class properties
Currently multi-dimensional packed vector class properties will cause an
assert and only single dimensional or scalar vectors will pass.

But just as for regular vectors there is nothing special about class
property multi-dimensional vectors as they will be represented in vector
form in vvp.

Removing the asserts allows multi-dimensional packed vectors to be used for
class properties. Indexed access to these properties is not supported yet;
that requires follow-up work to elaborate packed property selects and to
support partial stores to vector class properties.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:18 -07:00
Lars-Peter Clausen c7530dbcc1 Add regression test for assignment patterns as queue method arguments
Check that assignment patterns are evaluated in the queue element type
context when they are passed to the queue `push_front()`, `push_back()` and
`insert()` methods.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-31 18:32:44 -07:00
Lars-Peter Clausen e47160c6a8 Evaluate queue method arguments in assignment-like contexts
The arguments of the queue `push_front()`, `push_back()` and `insert()`
methods are passed to subroutine input ports. This makes them
assignment-like contexts with the declared argument type as target type.

Use `elaborate_rval_expr()` instead of `elab_and_eval()` for these
arguments. This evaluates the item argument with the queue element type and
the `insert()` index argument with `integer`, so target-type-dependent
expressions such as assignment patterns work and enum compatibility checks
use the queue element type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-31 18:32:44 -07:00
Cary R. 311c22e4de
Merge pull request #1373 from MrCookieeeee/Ignore-configure-generated-files
Ignore configure generated files
2026-05-22 10:15:55 -07:00
Cary R. 2d3502f4b7
Cleanup .gitignore organization and files 2026-05-22 10:14:31 -07:00
Cary R e54b404700 Update driver make check to work with all systems 2026-05-22 00:28:27 -07:00
Cookie 297dbe94c2 Ignore configure generated files 2026-05-22 15:05:02 +08:00
Cary R. 7b2c050457
Merge pull request #1371 from rhabacker/fix-issue-1370
iverilog: add command line option -BI and -Bt
2026-05-21 09:38:57 -07:00
Cary R. 6a6ff90197
Update clean target in Makefile to remove test.conf
Remove test.conf from the clean target in Makefile.
2026-05-21 09:27:48 -07:00
Cary R aafda65b99 Cppcheck cleanup 2026-05-21 05:21:35 -07:00
Cary R. 129a5c980f
Merge pull request #1369 from larsclausen/unpacked-array-assign-strength-delay
Preserve delay and strength in unpacked array continuous assignments
2026-05-20 18:49:41 -07:00
Cary R. da42011b97
Merge pull request #1372 from larsclausen/netevwait-repeat-control
NetEvWait: Don't delete event in destructor
2026-05-20 18:41:38 -07:00
Lars-Peter Clausen e35c857a24 Extend non-blocking event control with <= 0 repeat test
Extend the non-blocking event control assignment tests to check that a 0 or
negative repeat value is handled correctly. In this case the assignment
should be executed like a regular non-blocking assignment and the event
control should be ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-19 21:00:56 -07:00
Lars-Peter Clausen 7e7d0ae94b NetEvWait: Don't delete event in destructor
`NetEvWait` deletes the event that is assigned to it when itself
is deleted. But the event is not owned by the `NetEvWait`, it is shared among
all consumers of the event. Deleting it when the `NetEvWait` is deleted can
result in undefined behavior.

This is mainly a problem for non-blocking event control assignments with a
zero or negative immediate valued repeat. In this case the `NetEvWait` will
be deleted as it is not needed.

```
reg x;
event e;
x <= repeat(1) @e 1'b0;
x <= repeat(0) @e 1'b1; // Assert triggered since in-use event is freed
```

Remove the delete to fix this. Events that end up being unused will be
freed by the nodangle functor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-19 21:00:39 -07:00
Ralf Habacker 0d74d5b211 iverilog: add test for the vvp example mentioned in the documentation
This test was added to verify the new options
in the `iverilog` program, which allow it to
be run from a build directory.

Since `iverilog` is not compatible with the MSYS2
runtime environment used in CI, the added test is
excluded on this platform.
2026-05-19 22:22:43 +02:00
Ralf Habacker 2e50fb2f06 iverilog: add -Bt option to find <target>.conf when using -t<target> in custom install or build dir 2026-05-18 14:01:02 +02:00
Ralf Habacker 8b861b4171 iverilog: add -BI option to support custom location for the ivl parser 2026-05-18 07:50:07 +02:00
Ralf Habacker ecb8a70bed iverilog: add missing -B<selector> options to man page and app usage 2026-05-18 07:49:42 +02:00
Lars-Peter Clausen 635bdd8eb8 Add regression tests for unpacked array continuous assignment strength and delay
Check that continuous assignments to unpacked net arrays preserve delay and
drive strength on the generated element drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 14:46:31 -07:00
Lars-Peter Clausen ab6a0e0799 Preserve delay and strength in unpacked array continuous assignments
Continuous assignments to unpacked arrays are expanded into per-element
BUFZ drivers. Currently this path drops the delay and drive strength from
the original continuous assignment, so `assign #5 a = b` updates the array
immediately and `assign (weak1, weak0) a = b` drives with the default
strength.

Pass the evaluated delay and strength values through the unpacked array
assignment helper and apply them to each generated element driver.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 14:34:25 -07:00
Lars-Peter Clausen 85c58d0a7a Use helper types for drive strengths and delays
Drive strengths and delays are often handled as a pair of drive values
and a rise/fall/decay triple. Add small helper types to carry these
groups and use them in the continuous assignment and gate/UDP elaboration
paths.

Use the same helper types when propagating drive and delay values through
netlist links.

Also add helpers for dumping the values in debug output. This keeps the
behavior consistent and fixes one small bug where some of the debug
dumps printed the pointer value for the delays, rather than the actual
delay values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 14:27:45 -07:00
Cary R. cc86f69a89
Merge pull request #1368 from larsclausen/net-decl-consolidation
Support SystemVerilog net declaration assignments
2026-05-17 12:16:25 -07:00
Lars-Peter Clausen 28e121c040 Add regression tests for net declaration assignments
Check that SystemVerilog net declarations can mix entries with and
without initialization.

Check that in SystemVerilog it is possible to do assignments within net array
declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:12:26 -07:00
Lars-Peter Clausen 02fa1a9978 pform_set_data_type(): Remove `net_type` parameter
`pform_set_data_type()` is now only called on wires that already have the
correct wire type set. There is no need to pass the same type to
`pform_set_data_type()` and set it again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:11:54 -07:00
Lars-Peter Clausen 3495889112 Support SystemVerilog net declaration assignments
SystemVerilog allows initialized and uninitialized net declaration entries to
be mixed in the same declaration, e.g. `wire x, y = 1'b1`. In Verilog,
either all nets need to have an initializer or non can have one.

In addition SystemVerilog also allows assignments to arrays of wires during
declaration. E.g. `wire a[3:0] = b;`

Currently there are two different rules for net declarations, one for each
of the Verilog variants. Combine these into a single rule to support
SystemVerilog mixed declarations as well as the assignment to array nets.

When running in Verilog mode still reject mixed initialized and
uninitialized with a check after the parsing.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:06:44 -07:00
Lars-Peter Clausen e7934d5e66 pform_makewire(): Fix indentation
The assignment handling block uses space-based indentation that does not match
the surrounding code.

Fix the indentation before changing the block.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:05:02 -07:00
Cary R 86546b5960 Set LD_LIBRARY for BSD so make check works 2026-05-16 23:17:11 -07:00
Cary R ca3a00a51a Update some vlog95 interface configurations 2026-05-16 23:17:11 -07:00
Cary R. e6cfb08dd6
Merge pull request #1367 from larsclausen/uarray-lvalue-concat
Handle single element static unpacked array assignments
2026-05-16 22:04:59 -07:00
Lars-Peter Clausen 74491cfe9f Add regression tests for single element unpacked array assignments
Check that continuous assignment of an assignment pattern to a single element
unpacked array is accepted. Check that assigning a scalar expression to the
whole unpacked array is rejected for both procedural and continuous
assignments.

Check that a selected element of a single element static unpacked array can be
used in a continuous l-value concatenation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 21:11:30 -07:00
Lars-Peter Clausen dea82c5a91 Handle single element static unpacked array assignments
Currently single element static unpacked arrays are not always treated as
unpacked arrays when elaborating assignment l-values. The net only has one pin,
so checks using `pin_count() > 1` treat the array as a scalar value and skip
the unpacked array path.

Use `unpacked_dimensions() > 0` instead of `pin_count() > 1` when checking
whether a signal is an unpacked array. This lets single element arrays follow
the same l-value elaboration paths as other unpacked arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 21:06:16 -07:00
Cary R. 8229ce1b49
Merge pull request #1366 from larsclausen/sv2023-type-param-restrictions
Add support for restricted type parameters
2026-05-16 17:44:12 -07:00
Lars-Peter Clausen 08479888b1 Add regression tests for restricted type parameters
Check that enum, struct, union and class restricted type parameters are
accepted. Check that mismatched default values and overrides are rejected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 17:29:32 -07:00
Lars-Peter Clausen 46c0526dab Add support for restricted type parameters
SystemVerilog 2023 allows type parameters to be restricted to a
specific kind of type, e.g. `parameter type struct T = T0`.

This is very similar to the type restrictions that can be applied to
forward typedefs.

Factor the support code from the typedefs into a standalone helper and
reuse it for both.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 17:20:40 -07:00
Cary R. 0f75156d37
Merge pull request #1365 from larsclausen/soft-unions
Support soft packed unions
2026-05-16 17:11:41 -07:00
Lars-Peter Clausen f8e9384689 Add regression tests for soft packed unions
Check that soft packed unions can have members with different widths.
Check that the `soft` qualifier implies `packed` and that nested soft
packed unions use the same representation recursively.

Also check that member bits are right-justified and that assignments to
narrower members leave the MSBs beyond the member bits unchanged. Check
that soft packed unions reject default member values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 16:46:57 -07:00
Lars-Peter Clausen fb3be420b4 Support soft packed unions
SystemVerilog 2023 adds soft packed unions. They are pretty much the same
as regular packed unions except they remove the restriction that all
elements have to have the same packed width.

The packed with of the union itself is the maximum packed width of any
element.

The bits of each member are right-justified towards the LSBs and this
representation is applied recursively to nested soft packed unions. The
existing packed union member offsets already use that layout. When
accessing a field that is smaller than the union itself upper bits are
ignored for both reading and writing.

The `soft` qualifier implies a packed union so both `union soft U { ... }`
and `union soft packed U { ... }` declare a soft packed union.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 16:43:06 -07:00