-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[major] Move Extmodule Params to Instantiation #46
base: main
Are you sure you want to change the base?
Conversation
This changes the format for FIRRTL external modules to move parameter values to the site of instantiation as opposed to being declared along with the extmodule definition. This has the added benefit of removing the "defname" as this is now unified with the name of the external module. Signed-off-by: Schuyler Eldridge <[email protected]>
This is only a sliver of where I and others (@darthscsi 👀 ) want to take parameters. However, this is the bare minimum cleanup that fixes a lot of weirdness around external modules. This also matches where I want to take the internal MFC representation of external modules. |
Also allow for SInt parameters.
Update EBNF grammar for external module parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we need to support / demonstrate parameters in UInt widths at least to make this change?
``` | ||
|
||
The widths of all externally defined module ports must be specified. Width | ||
inference, described in [@sec:width-inference], is not supported for module | ||
ports. | ||
|
||
Externally defined modules may have zero or more parameters. Parameters may be | ||
of known-width `UInt`{.firrtl} or `SInt`{.firrtl} types or `String`{.firrtl} | ||
type. The value of a parameter is set at each instantiation of an external |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we mention that they must be passed in declaration order (there is no name-specified parameter passing syntax)
Yes, the extmodules are currently expressing the result of their parameterization, which needs to be fixed before we can move the parameters to the instances. |
Yes. I totally missed this. Currently you can do this with multiple extmodules with the same defname, different parameters, and different widths. This is going to bloat this PR a bit as it gets into parameter expression operations. More to follow... The most basic example of this is we need to deal with something like:
This needs to be represented as something like:
|
Make parameter types explicitly boxed. Restrict the locations where parameter types can show up to nodes and external module parameters. Allow aggregate, passive parameter types. Add a new parameter primitive operation section. This is presently incomplete, but includes a single `primAdd` operation to show how this would work. Update the EBNF grammar and the FIRRTL syntax highlighting XML file.
I updated this with a couple of changes:
There issues that need to be ironed out related to parameter directionality. E.g., are there input and output parameters? As it came up in offline discussions, this change has impacts on how deduplication works. However, I don't expect it to change any deduplication behavior. Examples follow: Example 1In the following circuit,
This is equivalent to the current situation now. The difference is that
Example 2If, on the other hand, the parameters passed to the external module instance are the same, then
This is equivalent to the current situation where an external module is instantiated twice:
Or where the external module is duplicated and should deduplicate:
Example 3There will need to be canonicalization/folding of parameters in order to cause situations like the following to properly recognize that two instances are the same. In the worst case, this requires walking backwards across expressions until you hit a root
|
a `Param`{.firrtl}` type. This indicates that this is a type that is used to | ||
express parameterization. Parameter types may be used to express | ||
parameterization on externally defined modules. Parameter types may be used as | ||
nodes. Parameter types may be used in passive aggregates. All other uses of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you show an example of "Parameter types may be used in passive aggregates"? what does that mean?
@@ -2910,6 +2976,17 @@ reference = id | |||
| reference , "[" , int , "]" | |||
| reference , "[" , expr , "]" ; | |||
|
|||
(* Parameter primitive operations *) | |||
primop_param_2expr_keyword = "add" ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
primop_param_2expr_keyword = "add" ; | |
primop_param_2expr_keyword = "paramAdd" ; |
if I am reading this right?
## Parameter Types | ||
|
||
A `UInt`{.firrtl}, `SInt`{.firrtl}, or `String`{.firrtl} type may be boxed with | ||
a `Param`{.firrtl}` type. This indicates that this is a type that is used to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a `Param`{.firrtl}` type. This indicates that this is a type that is used to | |
a `Param`{.firrtl} type. This indicates that this is a type that is used to |
@@ -27,6 +27,7 @@ | |||
<item>Clock</item> | |||
<item>Reset</item> | |||
<item>AsyncReset</item> | |||
<item>Param</item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit/FWIW: Param is special as it wraps other types. I ran into this for Ref
and wanted the inner types formatted so handled it like this: dtzSiFive/firrtl-spec@dtzSiFive:0190aba...dtzSiFive:abdbca8#diff-fc53c821ad3e7a3caa0a87f0f46f48202fca3bc55dbb9e56fc34cb0c6ec3ead3 . I think same would work for Param
, as another "outertype", and while I think that could be narrowed a bit regardless we can probably use same approach here.
(Not sure about the other grammar changes)
This changes the format for FIRRTL external modules to move parameter values to the site of instantiation as opposed to being declared along with the extmodule definition. This has the added benefit of removing the "defname" as this is now unified with the name of the external module.
Signed-off-by: Schuyler Eldridge [email protected]