Skip to content

Verilog: import of tasks/functions in interfaces and modports - #2115

Draft
kroening wants to merge 1 commit into
mainfrom
kroening/fix-interface-import
Draft

Verilog: import of tasks/functions in interfaces and modports#2115
kroening wants to merge 1 commit into
mainfrom
kroening/fix-interface-import

Conversation

@kroening

Copy link
Copy Markdown
Collaborator

Fixes the two frontend bugs documented as KNOWNBUG by #2113 and flips both tests to CORE.

interface/modport_import1 — parser (IEEE 1800-2017 §25.7)

A modport may import interface tasks/functions via import in the modport item list. The parser rejected this with syntax error, unexpected import. Adds a modport_tf_port rule (method_prototype | tf_identifier) plus import/export alternatives to modport_ports_declaration, with two new IREP IDs (verilog_modport_import/verilog_modport_export). No new grammar conflicts.

interface/package_import1 — elaboration (IEEE 1800-2017 §26.3)

A package import inside an interface body made imported typedefs visible, but calling an imported function failed with unknown function. convert_expr_function_call resolved the callee only in module and compilation-unit scope, ignoring the import/preresolved attributes that scanner.l already attaches to imported identifiers. It now consults those attributes first (mirroring convert_verilog_identifier) before the module/unit fallback. This also fixes the same call form in modules.

Testing

  • make -C src builds clean.
  • make -C regression/verilog test passes; modport_import1 and package_import1 now run as OK (previously SKIPPED as KNOWNBUG), and nothing else regressed.
  • Both tests emit no properties / EXIT=10; the must-not-match blocks (syntax error, CONVERSION ERROR) no longer appear, so each flips from KNOWNBUG to CORE, following the elsif3 precedent (Verilog: fix elsif-chain dual-emission in preprocessor #2112).

Fix the two frontend bugs documented as KNOWNBUG by PR #2113 and flip both
tests to CORE.

modport_import1: IEEE 1800-2017 25.7 allows a modport to import interface
tasks/functions via 'import' in the modport item list. The parser rejected
this with 'syntax error, unexpected import'. Add modport_tf_port and the
import/export alternatives to modport_ports_declaration.

package_import1: a package import inside an interface body (IEEE 1800-2017
26.3) made imported typedefs visible but calling an imported function failed
with 'unknown function'. convert_expr_function_call ignored the import and
preresolved attributes that scanner.l attaches to identifiers; consult them
before falling back to module/unit scope.
@kroening
kroening marked this pull request as draft August 21, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant