Skip to content

[FIRRTL] Support probe ports in instance_choice operations#9815

Draft
uenoku wants to merge 4 commits intomainfrom
dev/hidetou/lower-xmr-4
Draft

[FIRRTL] Support probe ports in instance_choice operations#9815
uenoku wants to merge 4 commits intomainfrom
dev/hidetou/lower-xmr-4

Conversation

@uenoku
Copy link
Member

@uenoku uenoku commented Mar 3, 2026

This commit adds support for read probe ports on instance_choice operations, enabling XMR lowering through instance choices where different target modules may have different internal probe paths.

For each ref port in an instance choice, the LowerXMR pass creates an internal macro (e.g., __targetref_Module_inst_port) and generates ifdef-guarded macro definitions in ref_.sv header files that select the appropriate XMR path based on the option value:

  `ifdef __option__Platform_FPGA
    `define __targetref_Top_inst_probe `__target_Platform_Top_inst.inner.r
  `elsif __option__Platform_ASIC
    `define __targetref_Top_inst_probe `__target_Platform_Top_inst.deep.r
  `else
    `define __targetref_Top_inst_probe `__target_Platform_Top_inst.r
  `endif

The implementation extends resolveReferencePath() to handle macro-based XMR paths without hierpaths, and adds VerbatimExprOp creation for these references.

RWProbe on instance choice ref ports are not yet supported.

AI-assited-by: Sonnet 4.5

uenoku added 3 commits March 2, 2026 19:47
This commit adds support for read probe ports on instance_choice operations,
enabling XMR lowering through instance choices where different target modules
may have different internal probe paths.

For each ref port in an instance choice, the LowerXMR pass creates an internal
macro (e.g., __targetref_Module_inst_port) and generates ifdef-guarded macro
definitions in ref_<module>.sv header files that select the appropriate XMR
path based on the option value:

  `ifdef __option__Platform_FPGA
    `define __targetref_Top_inst_probe `__target_Platform_Top_inst.inner.r
  `elsif __option__Platform_ASIC
    `define __targetref_Top_inst_probe `__target_Platform_Top_inst.deep.r
  `else
    `define __targetref_Top_inst_probe `__target_Platform_Top_inst.r
  `endif

The implementation extends resolveReferencePath() to handle macro-based XMR
paths without hierpaths, and adds VerbatimExprOp creation for these references.

RWProbe on instance choice ref ports are not yet supported.

// Register the internal macro as the XMR path for this port.
SmallString<128> macroPath("`");
macroPath.append(internalMacroName);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is abusing suffix to embed macroname directly. We could implement slightly nicer by extending XMRDerefOp to allow macro subst (but still need macro so not much difference TBH).

@uenoku uenoku force-pushed the dev/hidetou/lower-to-2 branch 2 times, most recently from 2490c10 to 0f5b6bb Compare March 4, 2026 11:03
Base automatically changed from dev/hidetou/lower-to-2 to main March 5, 2026 00:18
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