Skip to content

Comments

Updates to firrtl documentation for primitives templates#2634

Open
rhf841 wants to merge 5 commits intomainfrom
docs
Open

Updates to firrtl documentation for primitives templates#2634
rhf841 wants to merge 5 commits intomainfrom
docs

Conversation

@rhf841
Copy link
Collaborator

@rhf841 rhf841 commented Feb 17, 2026

No description provided.

@rhf841 rhf841 requested a review from ayakayorihiro February 17, 2026 00:30
@rhf841 rhf841 enabled auto-merge (squash) February 17, 2026 00:32
@rhf841 rhf841 disabled auto-merge February 17, 2026 00:32
Copy link
Contributor

@ayakayorihiro ayakayorihiro left a comment

Choose a reason for hiding this comment

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

This is looking good! I left a couple of comments about things we should change before we merge.

}
}
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, since we're writing all of this - can you also add some documentation about adding primitives to firrtl option too (which is to just add the SystemVerilog implementation of the primitive to primitives-for-firrtl.sv)?

### Adding Primitives for `firrtl-with-primitives`

1. **Create a Template:** Add a `.fir` file to `tools/firrtl/templates/`. The filename should match the primitive name (e.g., `std_add.fir`).
2. **Define the Interface:** The template must define a `module` whose ports (names and widths) exactly match the `extmodule` emitted by the Calyx backend in `calyx/backend/src/firrtl.rs`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I don't think the FIRRTL backend emits extmodules when we use it for firrtl-with-primitives (the build.ninja file in the generated fud2 directory will show you this, we can look through this next wednesday if you'd like). Maybe you mean something else?

1. **Create a Template:** Add a `.fir` file to `tools/firrtl/templates/`. The filename should match the primitive name (e.g., `std_add.fir`).
2. **Define the Interface:** The template must define a `module` whose ports (names and widths) exactly match the `extmodule` emitted by the Calyx backend in `calyx/backend/src/firrtl.rs`.
3. **Update the Replacement Map:** If your primitive uses unique parameters, update the replacement map logic in `tools/firrtl/generate-firrtl-with-primitives.py`.
4. **Testing:** Add a `runt` test in `tests/firrtl/primitive-templates` to ensure the new implementation generates valid FIRRTL and produces correct simulation results.
Copy link
Contributor

Choose a reason for hiding this comment

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

yay testing!!

@rhf841 rhf841 requested a review from ayakayorihiro February 22, 2026 23:31
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