-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Calyx-FIRRTL] Script for generating FIRRTL primitives #1863
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm going to close this PR since I later realized that I should link it with #1864 ! Sorry for the confusion. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed briefly in #1860 , FIRRTL modules are monomorphic; i.e. you cannot pass parameters into modules in the same fashion that you can pass parameters to Calyx primitives. Therefore, we need to generate specific FIRRTL modules that represent a Calyx primitive usage that we later instantiate in our code. The first step towards this was writing a backend (
primitive-uses
) that generates a JSON file that contains all of the primitive uses in a particular Calyx program (#1860).This PR contains a Python script (
generate-firrtl-primitives.py
) that uses the primitive usage information (in the JSON file) to produce FIRRTL modules for all the primitives that the associated Calyx program needs. It uses templated FIRRTL primitive files (intools/firrtl/templates
) and m4 to fill in the templates.Please let me know if there's anything in
tools/firrtl/generate-firrtl-primitives.py
that I can fix! (I currently have a small hack in the script that I'm not sure how to bypass...) Or if my approach of adding 20 template FIRRTL files is not ideal.I will be testing (once I get a test harness working... still working on it) the FIRRTL primitive templates, so I expect at least some of them to need fixes later. I'm also currently working on E2E fud2 FIRRTL support that pipelines the whole process together.
Usage
First, use the
primitive-uses
backend to produce a JSON file.ex)
Then, run the script. It takes in a single argument (the location of the previously generated JSON file) and prints out the FIRRTL primitives:
ex (continuing from above))