calyx icon indicating copy to clipboard operation
calyx copied to clipboard

eDSL: `static_if_with`

Open anshumanmohan opened this issue 1 year ago • 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 https://github.com/cucapra/calyx/pull/1783#discussion_r1398491603

anshumanmohan avatar Nov 19 '23 20:11 anshumanmohan

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

sampsyo avatar Nov 22 '23 17:11 sampsyo

Ah yes! So sorry, fixing now!

anshumanmohan avatar Nov 22 '23 17:11 anshumanmohan