Skip to content

Fix Verilog top module detection for modules with a parameter block#313

Open
hendrikmennen with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-top-module-detection
Open

Fix Verilog top module detection for modules with a parameter block#313
hendrikmennen with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-top-module-detection

Conversation

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

A Verilog module declared with a parameter block (#( ... )) before its port list was not recognized as a top module. VerilogNodeProvider.ParseModules consumed the balanced parameter block but did not skip whitespace before expecting the port-list (, so any newline/space between ) and ( caused the module to be misclassified as portless and dropped.

module my_custom_top #(
    parameter DATA_WIDTH = 32
)
(                        // <- whitespace/newline here caused the module to be skipped
    input wire clk,
    output reg data_out
);
endmodule

Changes

  • Parser fix (src/OneWare.Verilog/Parsing/VerilogNodeProvider.cs): skip whitespace after the #( ... ) parameter block before matching the port-list (.
  • Testability refactor: extracted internal static string-based helpers (ExtractNodes, ExtractTopEntities) so parsing can be tested on raw source without constructing an IProjectFile. The public file-based API is unchanged.
  • Tests: new tests/OneWare.Verilog.UnitTests project (added to OneWare.slnx, wired via InternalsVisibleTo) covering parameterized modules with and without whitespace before the port list, plain modules, and port extraction.

Co-authored-by: hendrikmennen <25281882+hendrikmennen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix top module detection for Verilog modules with parameter blocks Fix Verilog top module detection for modules with a parameter block Jul 10, 2026
Copilot AI requested a review from hendrikmennen July 10, 2026 16:13
@hendrikmennen hendrikmennen marked this pull request as ready for review July 10, 2026 16:51
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.

Bug: Top module detection fails if Verilog module contains a parameter block

2 participants