Skip to content

[FIRRTL] Add configuration file support for FIRRTL instance choices#9870

Open
uenoku wants to merge 1 commit intollvm:mainfrom
uenoku:dev/hidetou/choice-file
Open

[FIRRTL] Add configuration file support for FIRRTL instance choices#9870
uenoku wants to merge 1 commit intollvm:mainfrom
uenoku:dev/hidetou/choice-file

Conversation

@uenoku
Copy link
Member

@uenoku uenoku commented Mar 7, 2026

This PR proposes a mechanism to configure options based on a single header file instead of tool arguments.

Previously, FIRRTL instance choices required configuration through command-line arguments. This change introduces support for a FIRRTL_CONFIGURATION_FILE macro that allows users to specify all configuration options in a single SystemVerilog header file.

For exmaple an user can create a user-config.svh that contains include statements of option header files and compile it with

-DFIRRTL_CONFIGURATION_FILE=user-config.svh -I<user-config.svh's parent>

This approach centralizes configuration management and simplifies the build process by replacing multiple command-line arguments with a single include file.

AI-assisted-by: Sonnet 4.5

This commit proposes a mechanism to configure options based on a single
header file instead of tool arguments.

Previously, FIRRTL instance choices required configuration through
command-line arguments. This change introduces support for a
FIRRTL_CONFIGURATION_FILE macro that allows users to specify all
configuration options in a single SystemVerilog header file.

For exmaple an user can create a `user-config.svh` that contains
include statements of option header files and compile it with
```
-DFIRRTL_CONFIGURATION_FILE=user-config.svh -I<user-config.svh's parent>
```

This approach centralizes configuration management and simplifies the
build process by replacing multiple command-line arguments with a
single include file.
[&]() {
StringRef body = R"(`define FIRRTL_CONFIGURATION_INCLUDED
`define _STRINGIFY(x) `"x`"
`include `_STRINGIFY(`FIRRTL_CONFIGURATION_FILE)
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 was added to allow -DFIRRTL_CONFIGURATION_FILE=configuration.svh (otherwise need escape-DFIRRTL_CONFIGURATION_FILE=\"configuration.svh\").

sv::IfDefOp::create(
b, "FIRRTL_CONFIGURATION_FILE_", [] {},
[&]() {
StringRef body = R"(`define FIRRTL_CONFIGURATION_INCLUDED
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
StringRef body = R"(`define FIRRTL_CONFIGURATION_INCLUDED
StringRef body = R"(

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