google / google/xls

Consider allowing conversion from bits type to structs, or some destructuring pattern

Open
#131 1 comment 2 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

[Noted by Traster on HackerNews](https://news.ycombinator.com/item?id=24356329), it could be convenient to have bits values be convertible into the bitfields of a struct for convenience purposes, and to mimic the convenience of this common operation in Verilog.

Since all of our structs are conceptually packed, we'd just need to define the field order (MSb to LSb field) and bits-within-the-field order, perhaps instead of using `as` for conversion in a cast style, we could make this ordering more explicit, or perhaps there's a globally sensible default, since Verilog always had the (generally considered "wart" or "trap") of permitting `[0:X]` and `[X:0]` syntaxes to be confused.

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.