google / google/xls

Simplify using struct parametric to change function interfaces and support typedefs.

Open
#718 0 comments 0 reactions 0 assignees View on GitHub
dslx enhancement 🧦 sox
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

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(
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(
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(
array_in : params.ArrayType,
index : u32,
stride : u8,
val : params.ElementType) -> params.ArrayType {
...
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.