xls
xls copied to clipboard
Simplify using struct parametric to change function interfaces and support typedefs.
Currently in order to parameterize the function interface using struct parametrics, something like the following needs to be written:
struct Params {
bit_width : u32,
num_elements : u32,
}
pub fn StridedArrayUpdate<params : Params,
W : u32 = params.bit_width,
N : u32 = params.num_elements >(
array_in : bits[W][N],
index : u32,
stride : u8,
val : bits[W]) -> bits[W][N] {
...
}
This issue is to simplify the usage to something similar to
struct Params {
bit_width : u32,
num_elements : u32,
}
pub fn StridedArrayUpdate<params : Params>(
array_in : bits[params.bit_width][params.num_elements],
index : u32,
stride : u8,
val : bits[params.bit_width]) -> bits[params.bit_width][params.num_elements] {
...
}
Even simpler would be to support typedefs
struct Params {
bit_width : u32,
num_elements : u32,
type ElementType = bits[bit_width],
type ArrayType = ElementType[num_elements],
}
pub fn StridedArrayUpdate<params : Params>(
array_in : params.ArrayType,
index : u32,
stride : u8,
val : params.ElementType) -> params.ArrayType {
...
}