Handshake: Circuit with optional result

I would like to express stream operations in the handshake dialect. One of these operations should drop incoming tuples depending on certain conditions, e.g., drop all numbers that are negative. Therefore, I would require a circuit that does not always produce results.

I tried to use never, but it’s not clear to me how one should use it. Furthermore, there exists no conversion of never to FIRRTL or HW.
Is this an infeasible approach or even impossible to achieve in the handshake dialect?

Could this be achieved with a conditional branch that either sends results to an output or a sink? I’m imagining something like:

handshake.func @drop_if(%cond: i1, %input: i32, %ctrl: none) -> (i32, none) {
  %true_val, %false_val = conditional_branch %cond, %input : i32
  sink %false_val : i32
  handshake.return %true_val, %ctrl : i32, none
1 Like

Something like this does indeed work for my case.
Thank you very much for your help.

Awesome, glad that helped.