google / google/xls

Optimize priority_sel with same values as cases

Open
#751 3 comments 0 reactions 0 assignees View on GitHub
good first issue optimizer
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

With a priority select with the same value for the cases, e.g.
```
x23: bits[27] = priority_sel(x10, cases=[x1, x1, x1, x1, x1], id=80, pos=[(0,21,29)])
```

remains untouched after optimization.
```
x23: bits[27] = priority_sel(x10, cases=[x1, x1, x1, x1, x1], id=80, pos=[(0,21,29)])
```

We can perform an optimization that reduces the amount of cases, and, thus the bits for the selector. The latter would enable less area in the HW design.

```
x11: bits[1] = or_reduce(x10)
x23: bits[27] = priority_sel(x11, cases=[x1], id=80, pos=[(0,21,29)])
```
Note that, although synthesis tools may perform these types/style of optimizations, from an XLS perspective, it would produce more readable Verilog and may enable quicker JIT execution.

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.