google / google/xls

Provide a replication operator for arrays/bits

Open
#1,693 2 comments 0 reactions 0 assignees View on GitHub
dslx enhancement
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)

Create arrays and bit vectors with replicated patterns. SystemVerilog provides the replication operator which works on both, so you can do stuff like:

```
int n[1:2][1:6] = '{2{'{3{4, 5}}}};
```

which is equivalent to:

```
'{'{4,5,4,5,4,5},'{4,5,4,5,4,5}}
```

Similarly, you can do:

```
{4{4'b1010, 4'b1001}}
```

which is equivalent to

`32'b10101001101010011010100110101001`

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

You could write for loops to do `update` and `bit_slice_update`. Or just copy-paste manually.

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

Support this in DSLX.

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.