-
Notifications
You must be signed in to change notification settings - Fork 222
Open
Labels
dslxDSLX (domain specific language) implementation / front-endDSLX (domain specific language) implementation / front-end
Description
Describe the bug
This does not work:
pub struct FixedPoint<NUM_BITS: u32, BINARY_EXPONENT: s32> {
data: uN[NUM_BITS],
}
#[test]
fn test_neg_exp() {
let a = FixedPoint<u32:2, s32:-1> { data: u8:0 };
}
because BINARY_EXPONENT is s32. It works if I change it to u32. I really do want a signed value, so this is not acceptable.
Error message, referring to BINARY_EXPONENT when I create a:
sN[32] vs uN[32]: Dimension s32:-1 must be a `u32` (soon to be `usize`, see https://github.com/google/xls/issues/450 for details).
Note that other parametric argument types which are useful to implementers are also disallowed, e.g. bool would have been useful to me to make a signed magnitude workaround:
pub struct FixedPoint<NUM_BITS: u32, EXPONENT_IS_NEGATIVE:bool, BINARY_UEXPONENT: u32>
but the above is also not allowed.
To Reproduce
Use the code above, try to compile.
Expected behavior
That I can make BINARY_EXPONENT signed without issues.
This would be very handy for making an open source fixed point library.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
dslxDSLX (domain specific language) implementation / front-endDSLX (domain specific language) implementation / front-end
Type
Projects
Status
No status