Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Lift signal bit widths into type system when Rust achieves proper support for const generics #13

Open
yupferris opened this issue Sep 4, 2020 · 3 comments

Comments

@yupferris
Copy link
Owner

yupferris commented Sep 4, 2020

This has basically always been the plan, but is on hold until everything is stable. This will be very much a breaking change but I can imagine a lot of user code actually won't look much different due to type inference.

It looks like this is the tracking issue min_const_generics, which is the minimal feature subset that will be stabilized first, but it's not quite sufficient.

@yupferris
Copy link
Owner Author

yupferris commented Nov 30, 2020

I believe this will also be required for this use case in order to be able to calculate bit widths for combined Signals - eg. a * b will produce a new Signal whose bit width is the sum of the bit widths of a and b respectively. This means the signature of mul will be something like fn mul<const N: u32, const M: u32>(a: &Signal<N>, b: &Signal<M>) -> Signal<N + M> which is not supported with only min_const_generics.

Note also that it's possible for N + M to exceed the maximum bit width supported by a particular kaze version, which also needs to be checked/reported at compile time. I haven't dug deeply enough to know which feature(s) are required/available in order to implement this.

@kaoet
Copy link

kaoet commented Sep 16, 2021

Is it possible to use https://docs.rs/typenum instead before the stablization of generic_const_exprs?

@yupferris
Copy link
Owner Author

yupferris commented Oct 27, 2021

Is it possible to use https://docs.rs/typenum instead before the stablization of generic_const_exprs?

Very interesting, it looks like this may have what we need. I’ll do some evaluation work and see if it meets our needs and if the resulting type errors are overwhelming or not.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants