The with
operator
#934
Replies: 3 comments
-
More thoughts from a discussion about these two options: It seems that we've kind of tangled ourselves in this mess because of the way The another comment is that the second proposal, enable-with, cannot express inlining correctly. Consider this program:
Where both |
Beta Was this translation helpful? Give feedback.
-
I'm not entirely following this; specifically, why scoped assignments would lead to the loss of local reasoning. Can you elaborate / provide an example? |
Beta Was this translation helpful? Give feedback.
-
You can't reason about the assignments inside any group in isolation; you have to look at the stack of all active continuous assignments at each group enable to really understand what's going on. For example, we have a papercut check to ensure that a register's |
Beta Was this translation helpful? Give feedback.
-
Calyx currently supports a
with
in three locations:invoke
,if
, andwhile
. The basic idea is that some operations need to execute a combinational group to make combinational components active during execution before reading values from the output ports of the respective combinational operator.The current
with
operator has the following nice properties:if
andwhile
and while the component is executed forinvoke
---it does not disrupt local reasoning of groups and control operators.comb
groups can be turned into normal groups using theremove-comb-groups
pass.I am going to claim that (1) & (2) are good and probably important properties to maintain when extending the language. There are two competing proposals for a more general
with
operator in my mind and we can evaluate them using these properties.Scoped
with
OperatorThis will define a generic
with
operator that can be used like any control operator and activates a combinational group:The semantics of the operator is that assignments within it are active during the entire scope of execution. In my opinion, this approach violates both (1) and (2). For example, when reasoning about
g1
, the compiler needs to be aware of the entire stack of combinational groups that may be currently active. Additionally, there is no way to compile this operator into simple groups since the values on the inputs in the combinational group may change between execution of internal groups.Enable
with
This is a more modest extension to the language and is in spirit of the other uses of
with
:This operator, like previous additions of
with
, is easy to implement and retains (1) and (2). Compiling away thewith
operation is as simple as copying all the assignments in the combinational group into the group.Given this, I'm leaning towards the second proposal but would like to hear other opinions about this. Both of these will allow implementation of inlining of invokes as discussed in #807.
Beta Was this translation helpful? Give feedback.
All reactions