Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] priority_sel should support any cases type #1729

Open
proppy opened this issue Nov 19, 2024 · 3 comments
Open

[enhancement] priority_sel should support any cases type #1729

proppy opened this issue Nov 19, 2024 · 3 comments
Labels
dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request 🧦 sox

Comments

@proppy
Copy link
Member

proppy commented Nov 19, 2024

What's hard to do? (limit 100 words)

currently priority_sel can only be used w/ scalar type (uN), see:
https://google.github.io/xls/dslx_std/#priority_sel

Current best alternative workaround (limit 100 words)

using one_hot in combination w/ a match expression decoding the one_hot result and cases w/ arbitrary expression allow support for compound type like struct, tuple and array.

Your view of the "best case XLS enhancement" (limit 100 words)

making priority_sel support arbitrary types in the case array.

@proppy proppy added enhancement New feature or request dslx DSLX (domain specific language) implementation / front-end 🧦 sox labels Nov 19, 2024
@proppy proppy changed the title [enhancement] priority_sel should support any case type [enhancement] priority_sel should support any cases type Nov 19, 2024
@ericastor
Copy link
Collaborator

ericastor commented Nov 19, 2024

This is a good idea for completeness, but it's worth noting that using a match expression will currently work just fine for arbitrary types - and as it happens, it compiles down to a priority_sel.

@proppy
Copy link
Member Author

proppy commented Nov 27, 2024

it's worth noting that using a match expression will currently work just fine for arbitrary types

Yes, I re-discovered this pattern which allow you to encode as priority_sel w/ arbitrary type as a match statement w/ exclusive condition:

match true {
   condition0 => result0,
   condition1 => result1,
   condition2 => result2,
   condition3 => result3,
}

@proppy
Copy link
Member Author

proppy commented Feb 6, 2025

I re-discovered this pattern

Note this is not actually working as stated above, see #1909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request 🧦 sox
Projects
Status: No status
Development

No branches or pull requests

2 participants