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][dslx] Consider the best way we might encode one-hot in the type system #1963

Open
cdleary opened this issue Feb 28, 2025 · 0 comments
Labels
dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request long-term-enhancement Issues that are sensible enhancements but XLS devs expect may not be addressed in the near-term

Comments

@cdleary
Copy link
Collaborator

cdleary commented Feb 28, 2025

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

One hot is a property of underlying data that lends itself nicely to a "witness type"; i.e. imagine you run one_hot on a value and then you pass that value to a function, it would have to similarly run one_hot on the value to know that it was indeed in one hot form. If we had a type that said "this value has been validated to be one hot" we could make the value's invariants more self documenting and avoid the need for redundant checks.

Current best alternative workaround (limit 100 words)

As noted above running one_hot on values to ensure they're canonically one hot, and perhaps adding asserts to check this when it is a precondition that it should be given as one hot.

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

Perhaps a built-in type like oN[N] to complement uN[N] and sN[N]? A standard library struct wrapper wouldn't allow built-ins to take or produce the type as easily.

@cdleary cdleary added enhancement New feature or request dslx DSLX (domain specific language) implementation / front-end long-term-enhancement Issues that are sensible enhancements but XLS devs expect may not be addressed in the near-term labels Feb 28, 2025
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 long-term-enhancement Issues that are sensible enhancements but XLS devs expect may not be addressed in the near-term
Projects
Status: No status
Development

No branches or pull requests

1 participant