calyxir/calyx

eDSL: `static_if_with`

Opened this issue · 2 comments

Just putting a bookmark down for an interesting use case that has a potentially cute solution. We have already have:

  • if_, which generates a Calyx if with a port but without a comb group.
  • if_with, which very neatly generates a Calyx if with a port and a comb group. It takes as input a cell and comb group, and uses cell.out as the if’s port. This cell and comb group tuple is generated via a different set of helpers, e.g. eq_use returns an eq cell and a comb group that performs an equality check using that cell. It is nice that we can then just pass this tuple to if_with.
  • static_if, which generates a Calyx static if with a port but without a comb group.

static_if_with is not what you think it is: static if in Calyx should have a port but should not have a comb group: those are disallowed in a static domain. Rather, the following should happen:

The command static_if_with(CellAndGroup, IfBody, ElseBody), should be processed by:

  1. Snapping apart the CellAndGroup into cell and group.
  2. Putting all of group's assignments into the component’s continuous assignment stanza.
  3. Turning the command into static_if(cell.out, IfBody, ElseBody)

Originally posted by @anshumanmohan in #1783 (comment)

Just checking: when you say static_if_while above, do you mean static_if_with?

Ah yes! So sorry, fixing now!