Skip to content

feat: Add support for blackbox modules in BELs#599

Open
EverythingElseWasAlreadyTaken wants to merge 1 commit intoFPGA-Research:mainfrom
EverythingElseWasAlreadyTaken:WIP/backbox_support
Open

feat: Add support for blackbox modules in BELs#599
EverythingElseWasAlreadyTaken wants to merge 1 commit intoFPGA-Research:mainfrom
EverythingElseWasAlreadyTaken:WIP/backbox_support

Conversation

@EverythingElseWasAlreadyTaken
Copy link
Collaborator

No description provided.

Signed-off-by: Jonas K. <j0nask@proton.me>
Copilot AI review requested due to automatic review settings February 17, 2026 18:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request modifies the getTopModule() method in the Yosys JSON parser to also accept modules with the "blackbox" attribute in addition to modules with the "top" attribute. The change aims to support blackbox modules in Basic Element of Logic (BEL) definitions, which are fundamental building blocks in the FPGA fabric.

Changes:

  • Modified getTopModule() logic to return modules with either "top" or "blackbox" attributes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""
for name, module in self.modules.items():
if "top" in module.attributes:
if "top" in module.attributes or "blackbox" in module.attributes:
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic change introduces a semantic problem. The method is called getTopModule() but now also returns modules with the "blackbox" attribute. In Yosys, "top" and "blackbox" are distinct concepts - "top" marks the top-level module of a design hierarchy, while "blackbox" marks primitive modules without implementation details. If a design contains both a top module and blackbox modules (which is common), this change will return whichever is encountered first in the dictionary iteration, which may not be the actual top module. Consider either: (1) prioritizing "top" over "blackbox" by checking for "top" first, or (2) if blackbox-only designs are intended, creating a separate method or documenting this behavior change explicitly.

Copilot uses AI. Check for mistakes.
Comment on lines 386 to 401
"""Find and return the top-level module in the design.

The top module is identified by having a "top" attribute.

Returns
-------
tuple[str, YosysModule]
A tuple containing:
- The name of the top-level module (str)
- The YosysModule object for the top-level module

Raises
------
ValueError
If no top module is found in the design.
"""
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring is now inaccurate. It states "The top module is identified by having a 'top' attribute" but the implementation now also accepts modules with a "blackbox" attribute. The docstring should be updated to reflect this change in behavior, explaining when and why blackbox modules are returned instead of top modules.

Copilot uses AI. Check for mistakes.
"""
for name, module in self.modules.items():
if "top" in module.attributes:
if "top" in module.attributes or "blackbox" in module.attributes:
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage is missing for the new behavior. The existing tests only verify modules with "top" attributes and modules with no attributes. A test should be added to verify the behavior when a module has a "blackbox" attribute, and ideally a test for when both "top" and "blackbox" modules exist to ensure the correct one is returned.

Copilot uses AI. Check for mistakes.
@KelvinChung2000
Copy link
Collaborator

This is fine, but I just like to understand why you need the blackbox attribute specifically, since this should support the blackbox top module. Does yosys not add the top when it is a blackbox?

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.

2 participants

Comments