google / google/xls

[enhancement] DSLX bit type indexing

Open
#1,568 3 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

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

If I try to write:

```
let foo: u23 = u23:0b10;
let bar = foo[1]; // expect u1:1
```

I get:

```
TypeInferenceError: uN[23] Value to index is not an array.
```

### Current best alternative workaround (limit 100 words)

You need to do a roundabout bit slice instead.

```
let bar = foo[1+:u1];
```

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

Support indexing, like we have in arrays. Note that this also works in Verilog and Python (I only reference Python because [the docs do](https://google.github.io/xls/dslx_reference/#bit-slice-expressions:~:text=DSLX%20supports-,Python%2Dstyle,-bit%20slicing%20over)).

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.