Replies: 3 comments
-
Currently, if you have your selectors in a 9-wide tuple called
If you'd like to recommend a syntactic sugar for match expressions of this form (not sure what to call it), that could be great! I'd probably suggest filing that as a new enhancement request. You almost certainly don't want to use an explicit NOTE: If your selectors are instead packed into a
Similarly, if they're packed into an array as
|
Beta Was this translation helpful? Give feedback.
-
Actually, I think we have one other option that's very clean if you can assume the selecting bools are one-hot. Assuming your selector bools are packed into a
This uses our standard-library function (https://google.github.io/xls/dslx_std/#encode) that translates a one-hot input into the number @dank-openai, what do you think of this option? NOTE: If your selectors are packed into an array, you can probably use an array conversion to get them into a
If they're instead packed into a tuple, you might need to concat them manually, but I'm not sure:
or
depending on the case ordering. |
Beta Was this translation helpful? Give feedback.
-
Is that similar to #1729 ? One workaround that I've been using (as discussed in #1913 and #1909) is:
which test |
Beta Was this translation helpful? Give feedback.
-
Originally posted by @dank-openai in #209
Summarizing the discussion: suppose we have a list of bools (maybe as a tuple, an array, or a uN[K]) and an array of values with the same width. We want to select the first entry in the array for which the corresponding bool is true.
How can we do this most cleanly & optimally in DSLX?
What if we know the set of bools is one-hot? Can we somehow make sure XLS emits optimal codegen for this, and skips priority resolution?
Beta Was this translation helpful? Give feedback.
All reactions