-
Notifications
You must be signed in to change notification settings - Fork 50
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
Annotations for Data Path Components #1169
Comments
The Filament issue above points out an optimization that this can enable in the backend: It occurs to me that this optimization should be done by Calyx and not Filament itself because this reasoning applies to all data ports. Specifically, rewriting:
into
Should always be safe |
Finally catching up on this very nice idea, @rachitnigam, after your helpful explanation today! I think the note about allowed optimizations above is especially important. It's a very cool upside that we can show that certain optimizations are allowed on always-never-undefined values that are not possible on maybe-undefined values!! Just to jot down some high-level thoughts that came out of today's brief discussion:
|
One important consequence of answering this question is whether the optimization can be represented in Calyx or not. If the compiler enforces this property then the optimization occurs in backend while the Calyx code is being compiled in Verilog. On the other hand, if programs are required to maintain it, then we can represent the optimization within Calyx. A middle ground solution is following the philosophy outlined in #518 and explicitly instantiating all the muxing in Calyx program before we even reach the backend. |
Yeah, good point. I think it could be fun to think a bit about what the IR would look like in the "required" version, and what the relevant lowering/optimization passes would look like. |
We need to say something stronger here:
In general, a lot of the computations are going to end up transitively related to assignments to a group's done signal. For example, here is an image of a part of the writes-to graph for The thing to notice is that most
We should still be able to mark In contrast, for something like this:
We would need to mark |
Hmm; interesting example. You observed:
Correct me if I'm wrong, but in the statically-checked version of this system, we would need to require anything used in a guard to be |
Yup! Guards are not allowed to "glitch" and hold |
Another shot to answer the evergreen undefinedness of undriven signals in Calyx (#922). In its most reduced operational form, it asks when is it safe to provide
'x
as the default value for a port instead of'0
.The core of this proposal are two new attributes:
@data
and@control
. The@data
attribute marks a cell as a data path component, and the@control
attribute marks a cell as a control path component. These attributes are mutually exclusive, and a cell can only have one of them.An instance marked with
@control
requires all its ports to have'0
as the default value. An instance marked with@data
additionally needs to mark some of its ports with the@data
attribute to state that these can accept'x
as the default value. This is because even for data path components, certain ports like thego
port might always need a non-'x
value.This proposal follows a safe-by-default approach to the problem: it is always safe to ignore the
@data
attributes and provide all ports with a default value of'0
. The@control
attribute is just a safety mechanism that can be used to catch errors early.Conditions for
@control
InstancesFollowing the things enumerated in #922, here is a list of some constraints the forces an instance to be a control instance:
if
orwhile
@go
port such aswrite_en
@control
instanceNote that if any port of an instance is used in these positions, the instance must be marked as a
@control
instance. Number (5) is the challenging one here since it's a recursive condition. However, I don't see any other way to address the problem of propagation of undefinedness from data path to the control path. The interesting question is whether this approach will leave any instances as@data
instances.We can design a new pass that can compute which cells are
@control
using the criteria above. If these conditions are necessary and sufficient, all the cells not marked with@control
are@data
cells.Semantics
Everything up till now gives a very operational view of how to address the undefinedness problem. However, it doesn't give us a clear view on what the exact semantic properties are. As far as I can tell, the semantics needs to be defined in terms of these attributes. There is no a priori way to define which signals are data path and which are control path; we can only call programs undefined given an assignment of attributes to instances.
The text was updated successfully, but these errors were encountered: