Commit Graph

10617 Commits

Author SHA1 Message Date
Cary R 614607c135 Cppcheck fixes in vvp 2026-07-14 01:31:09 -07:00
Cary R dec4e939f4 Fix compile issues in previous patch 2026-07-14 00:09:31 -07:00
Cary R e367080276 Fix incorrect definition 2026-07-14 00:09:24 -07:00
Cary R e4bede3c76 Fix some compile warnings under mingw/cygwin 2026-07-13 23:51:10 -07:00
Cary R. 812c1cedcb
Merge pull request #1418 from muhammadjawadkhan/split/02-sv-chained-calls
SV: chained method calls a().b()
2026-07-13 23:05:04 -07:00
Cary R. 67d39803e6
Fix formatting and add braces for clarity 2026-07-13 22:54:26 -07:00
Cary R. 55250457ed
Fix formatting in parse.y for call_chain_expr 2026-07-13 22:50:55 -07:00
Cary R. 29a8a4d052
Simplify conditional checks in elab_expr.cc 2026-07-13 22:48:28 -07:00
mjoekhan 4a505546a1 SV: chained method calls a().b()
Add parsing and elaboration for chained calls on expression results,
with sv_call_chain_method1 regression.

Split from steveicarus/iverilog#1330 (part 02/6).
2026-07-13 18:48:30 +05:00
Cary R 15689210c1 Fix the building of libvvp.pc 2026-07-12 17:33:29 -07:00
Cary R e5482b89b1 Fix compile warning 2026-07-12 10:05:55 -07:00
Cary R d376375020 Fix br1005 tests for fsv and vlog95 2026-07-12 10:05:49 -07:00
Cary R. d15f24ff49
Merge pull request #1416 from muhammadjawadkhan/split/01-sv-class-queue-darray-props
SV: class queue/darray property foundation
2026-07-12 08:18:25 -07:00
Cary R. 2ff0be6bfd
Fix conditional check for net class type 2026-07-12 08:00:14 -07:00
Cary R. e7233856c8
Simplify conditional return statements 2026-07-12 07:57:09 -07:00
Cary R. 9a7178fef0
Refactor format_darray_pretty for readability 2026-07-12 07:52:48 -07:00
Cary R. 82350c4866
Fix conditional block for boolean type handling 2026-07-12 07:44:20 -07:00
Cary R. 4d07a8466c
Merge pull request #1439 from larsclausen/ams-type-id-shadow
Support discipline and nature names shadowing type identifiers
2026-07-12 07:20:11 -07:00
Lars-Peter Clausen 0e3ac8685c Add regression tests for discipline and nature type identifier names
Check that nature and discipline declaration names can match visible type
identifiers. Also check `potential` and `flow` references to nature names that
are visible as type identifiers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 17:47:52 -07:00
Lars-Peter Clausen 1d623a67d1 Support discipline and nature names shadowing type identifiers
Verilog-AMS nature and discipline declarations can use names that are also
visible as type identifiers. The `potential` and `flow` discipline items can
likewise reference a nature whose name is returned as `TYPE_IDENTIFIER` by the
lexer. These grammar positions currently only accept `IDENTIFIER`.

Use `identifier_name` for nature and discipline declaration names and for the
`potential` and `flow` nature references.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 17:44:54 -07:00
Lars-Peter Clausen a540a7a163 Add regression tests for for and foreach type identifier names
Check that a for loop variable declaration can use the same name as a
visible typedef, including references from the loop condition and step
expressions.

Also check that procedural foreach can parse an array expression name that
is initially seen as a type identifier. Declare the array after the loop so
the parser sees the outer typedef while parsing the foreach header, then
elaboration resolves the array declaration as a module item.

Use unsigned variables and omit the foreach iterator because these tests do
not depend on signed values or iteration behavior. This lets both tests run
through the vlog95 backend as normal regressions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:18 -07:00
Lars-Peter Clausen 9ec8f8e2dd Support for and foreach identifiers shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as
a type identifier from an outer scope. The lexer reports such names as
`TYPE_IDENTIFIER` until the new declaration has been installed.

The parser previously created the synthetic loop scope and declared the loop
variable only after parsing the complete `for` header. When the variable name
matches a visible typedef, this is too late: the lexer can continue returning
`TYPE_IDENTIFIER` for references to the variable in the initializer,
condition, and step expressions. Accept `identifier_name` for the declaration
name and create the loop scope and variable in a mid-rule action immediately
after it, so the declaration is visible while the rest of the header is
parsed.

The executable foreach grammar also used to require the array expression name
before the index list to be an `IDENTIFIER`. Use `identifier_name` there as
well, since this position is an expression name followed by `[` and not a type
name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:18 -07:00
Lars-Peter Clausen 36a79568b7 Add regression tests for attribute names matching type identifiers
Check that a standard attribute name can match a visible typedef. Also check
that the global `$attribute` extension can target a primitive whose name is
visible as a type identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:02 -07:00
Lars-Peter Clausen ee14022127 Support type identifier names in attributes
Standard attribute names and target names in both forms of the Icarus
`$attribute` extension are unambiguous identifier positions. When such a name
matches a visible typedef the lexer returns `TYPE_IDENTIFIER`, while the
grammar only accepts `IDENTIFIER`.

Use `identifier_name` for all of these positions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:02 -07:00
Cary R. 0723d9a477
Merge pull request #1435 from larsclausen/br-gh1385-vlog95
ivtest: Run nested enum tests through vlog95
2026-07-10 10:43:04 -07:00
Cary R. f8069416f2
Merge pull request #1434 from larsclausen/parameter-omit-implicit-type
parser: Reject implicit parameter types without parameter
2026-07-10 10:42:15 -07:00
Lars-Peter Clausen c0cf842eb2 ivtest: Move parameter omit tests to JSON
The parameter_omit tests have different expectations depending on whether the
regression is run in the default Verilog mode or with force SystemVerilog.
The old list files modelled this by registering the same tests in both
regress-vlg.list and regress-fsv.list.

Move the tests to JSON descriptors. Use the existing force-sv override for the
forms that are valid SystemVerilog, and keep the implicit type cases as CE in
both modes. This also runs the tests through the additional configurations
supported by vvp_reg.py, providing better coverage in CI.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:49:01 -07:00
Lars-Peter Clausen 20a34d33c6 parser: Reject implicit parameter types without `parameter`
The LRM allows omitting the `parameter` keyword in a module parameter port
list, but the optional type in that form is a data_type, not an implicit
data type. A parameter port list like this is therefore invalid:

    module M #([3:0] P = 1);

The parameter declaration grammar was reusing the general
value_parameter_assign_with_type rule for the omitted-keyword form. That rule
also accepts implicit types so that ordinary `parameter signed P = 1`
declarations work, which made the omitted-keyword form accept implicit types
as well.

Add a separate rule for value parameter assignments without the `parameter`
keyword. The rule still accepts bare identifiers and explicit data types so a
parameter name can shadow a visible typedef name, but it rejects implicit
types.

Fixes: e56c93a2be ("Support shadowing type identifiers in parameter declarations")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:49:01 -07:00
Lars-Peter Clausen f870c755fa ivtest: Run nested enum tests through vlog95
The br_gh1385a, br_gh1385b, and br_gh1385c JSON descriptors mark the vlog95
variants as compile errors. The enum typedefs are translated correctly, so the
compile error expectation causes the tests to fail when compilation succeeds.

Remove the stale overrides and run the translated tests through vlog95.

Fixes: 10349287a0 ("Add regression tests for enum typedefs in nested scopes")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:45:55 -07:00
Lars-Peter Clausen 3e0c298b25 Add regression tests for named selectors matching typedef names
Check that a named binding selector can have the same text as a visible typedef
name. Cover named module port connections, named parameter overrides, and named
task, function and constructor arguments.

Also check that a modport simple port selector can shadow a visible typedef
name. Modport simple port aliases share the same parser rule but declare the
modport-visible name rather than binding to an existing formal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:08:25 -07:00
Lars-Peter Clausen 6844ed4194 Accept type-identifier tokens in named binding selectors
A named binding selector such as `.T(expr)` names an existing formal port,
parameter, task or function argument, or constructor argument. It is not a
declaration of a new identifier. If a visible typedef named `T` exists at the
use site the lexer returns `TYPE_IDENTIFIER`, which made the parser reject the
binding selector.

Modport simple port aliases use the same grammar, but are slightly different:
the selector is the modport-visible port name and can shadow a visible typedef
name in the interface scope.

Use `identifier_name` for the selector name in `named_expression` and
`named_expression_opt`. This covers named parameter overrides, named task and
function arguments, named constructor arguments, and modport simple port
aliases. Also use `identifier_name` in the named module port connection rules,
including implicit named port connections and error recovery.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:08:25 -07:00
mjoekhan 9880fb8d5e SV: class queue/darray property foundation
Fold in Windows VPI routing for vpip_format_pretty, fix queue method
argument elaboration via elaborate_rval_expr, reject class tasks used as
expressions cleanly, and update br1005 now that class queues compile.

Review follow-up: move vpip_format_pretty to vpip_format.cc with
diagnostic return strings, restore NetNet-based queue method elaboration
with a separate property path, drop spurious /devel/ from .gitignore,
and bump copyright years on touched files.

Formatting pass per inline review: brace style for multi-line if bodies,
||/&& at end-of-line continuations, switch/case indentation, single-line
if returns, NetNet-based sys_task_method_ again, and aligned extern decls.
2026-07-07 00:46:45 +05:00
Cary R. e02a0bc2ec
Merge pull request #1431 from larsclausen/event-variable-type-id-shadow
Support event names shadowing type identifiers
2026-07-06 09:32:00 -07:00
Lars-Peter Clausen abfb4e83bc Add regression test for event names shadowing type identifiers
Check that event declarations can use visible type identifiers as event names.
Also check that the resulting named event can be triggered and waited on.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:44:44 -07:00
Lars-Peter Clausen 17ca0948f4 Support event names shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as a
type identifier from an outer scope. This also applies to named event
declarations. The lexer reports such names as `TYPE_IDENTIFIER` before the
event has been installed, which made constructs such as:

    typedef int T;
    module test;
      event T;
    endmodule

fail in the event declaration grammar.

Event declarations do not have the local type/name ambiguity that exists for
variable, net, or parameter declarations. The name in `event_variable` is
always the event name. Use `identifier_name` so a `TYPE_IDENTIFIER` token can
be accepted as the event name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:44:44 -07:00
Lars-Peter Clausen f6848300b7 Add regression tests for block labels shadowing type identifiers
Check that visible type identifiers can be reused as named block labels. Cover
procedural `begin` blocks, fork blocks, and conditional generate blocks. Also
check matching end labels where the grammar consumes the shared `label_opt`
rule.

The generate test keeps the existing vlog95 compile-error expectation because
named generate scopes are not translated by the vlog95 target.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:32 -07:00
Lars-Peter Clausen 06740d0dda Support block labels shadowing type identifiers
SystemVerilog allows a named block label in an inner scope to use the same
name as a visible type identifier from an outer scope. The lexer reports such
names as `TYPE_IDENTIFIER` before the label has been installed, which made
constructs such as:

    typedef int T;
    module test;
      initial begin
        begin : T
        end : T
      end
    endmodule

fail in the block label grammar.

The affected grammar positions are label names, not declarations with an
adjacent type/name ambiguity. Use `identifier_name` for `label_opt` and for the
anachronistic named generate begin form so a token returned as `TYPE_IDENTIFIER`
can still be accepted as the label name. With `label_opt` able to handle
`TYPE_IDENTIFIER`, the separate class end-label rule is no longer needed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:32 -07:00
Lars-Peter Clausen 15277c9fa4 Add regression test for package names shadowing type identifiers
Check that a package declaration can use a visible type identifier as its
package name. Also check that the resulting package scope can be selected with
a scope-qualified reference.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:18 -07:00
Lars-Peter Clausen ca5c6fc59f Support package names shadowing type identifiers
SystemVerilog allows a package declaration to use a name that is also visible
as a type identifier. The lexer reports such names as `TYPE_IDENTIFIER` before
the package has been installed, which made constructs such as:

    package p;
      typedef int T;
    endpackage
    import p::*;
    package T;
    endpackage

fail in the package declaration grammar.

Package declarations do not have the local type/name ambiguity that exists for
variable, net, or parameter declarations. After the optional lifetime the next
token is always the package name. Use `identifier_name` so a
`TYPE_IDENTIFIER` token can be accepted as the package name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:18 -07:00
Lars-Peter Clausen 2cef311be2 Make Bison parser conflicts errors
Bison reports shift/reduce and reduce/reduce parser conflicts as warnings by
default. This allows parser changes to introduce new conflicts while the normal
build still succeeds.

Pass the conflict warning classes as errors to Bison when generating the
parsers. This makes the regular build fail if either parser has unresolved
conflicts.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:03 -07:00
Lars-Peter Clausen ff0b4a3154 parser: Fix parameter assignment grammar conflict
The parameter declaration grammar allows a visible type identifier to be used
as a parameter name. The assignment continuation rule still used
`identifier_name`, which made Bison reduce a `TYPE_IDENTIFIER` before it had
seen whether following dimensions belonged to the parameter name or to an
explicit type identifier.

Match ordinary and type identifiers directly in `parameter_assign` so the
parser can shift dimensions before deciding between a parameter name and an
explicit parameter type.

Fixes: e56c93a2be ("Support shadowing type identifiers in parameter declarations")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:03 -07:00
Lars-Peter Clausen 2b67d9f754 Add regression tests for UDP names shadowing type identifiers
Check that UDP primitive and port names can shadow visible type identifiers.
Cover old-style UDP declarations, including input and output declarations and
the initial target, as well as ANSI-style UDP port declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:58:11 -07:00
Lars-Peter Clausen 56c42dcf37 Support UDP names shadowing type identifiers
SystemVerilog allows a UDP primitive or UDP port declaration to use the same
name as a visible type identifier from another namespace or outer scope. The
lexer reports such names as `TYPE_IDENTIFIER` before the UDP name has been
installed, which made constructs such as:

    typedef int T;
    primitive T (Q, A);
      output Q;
      input A;
      table
        0 : 0;
      endtable
    endprimitive

fail in the UDP grammar.

UDP primitive and port names do not have the local type/name ambiguity that
exists for variable, net, or parameter declarations. Use `identifier_name` for
the primitive name, the UDP port list, UDP port declarations, and the UDP
initial target so a `TYPE_IDENTIFIER` token can be accepted as the UDP name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:58:11 -07:00
Lars-Peter Clausen c8568998af Add regression tests for UDP declaration diagnostics
Check that UDP initial values on non-registered outputs generate compile
errors for both old-style and ANSI-style UDP declarations. Also check that
conflicting UDP port declarations generate an error and that a valid
ANSI-style `output reg` initializer is accepted.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:57:30 -07:00
Lars-Peter Clausen 8d4faf2744 Report UDP declaration errors instead of asserting
Malformed UDP declarations can reach `pform_make_udp()` with conflicting
duplicate port declarations or with an initial value on an output that was not
declared as a register. These cases currently trigger internal assertions
instead of reporting normal compile errors.

The ANSI-style UDP output initializer path also treats the initializer
expression as if it was the old-style `initial out = value` assignment
statement. This makes a valid `output reg out = 1'b0` initializer assert as
well.

Report errors for the invalid declarations and read the ANSI-style initializer
value directly from the initializer expression.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:57:30 -07:00
Cary R. 025cbcc81f
Merge pull request #1426 from larsclausen/enum-item-type-id-shadow
Support enum items shadowing type identifiers
2026-07-04 07:29:07 -07:00
Cary R. b6829ab504
Merge pull request #1425 from larsclausen/taskfunc-type-id-shadow
Support task and function names shadowing type identifiers
2026-07-04 07:26:52 -07:00
Lars-Peter Clausen 43817251f4 Add regression test for enum items shadowing type identifiers
Check that enum item names can shadow visible type identifiers. Cover plain enum
items as well as the counted and ranged enum item sequence forms.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 18:13:51 -07:00
Lars-Peter Clausen 0c7341be37 Support enum items shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as a
type identifier from an outer scope. This also applies to enum item names. The
lexer reports such names as `TYPE_IDENTIFIER` before the enum item has been
installed, which made constructs such as:

    typedef int T;
    module test;
      enum { T = 1 } e;
    endmodule

fail in the enum item grammar.

Enum item declarations do not have the local type/name ambiguity that exists for
variable, net, or parameter declarations. The name in each `enum_name`
production is always the enum item name, including the sequence forms like
`T[2]` and `T[1:2]`. Use `identifier_name` for these names so they can shadow a
visible type identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 18:10:54 -07:00
Lars-Peter Clausen 21b0107bae Add regression tests for type identifier task and function names
Check that function and task declarations can use a visible type identifier as
the declaration name. Cover both ANSI declarations and the non-ANSI forms where
the name is parsed without a separate return type or port list.

Also check class method declarations where the method name is the same as the
enclosing class name. Add GitHub issue #670 coverage for the `function void`
case using the issue-based regression naming scheme.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 17:33:07 -07:00