Skip to content

Add an RFC for ShapeCastable.from_bits and lib.data.Const. #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

wanda-phi
Copy link
Member

@whitequark whitequark added meta:nominated Nominated for discussion on the next relevant meeting area:core RFC affecting APIs in amaranth-lang/amaranth labels Mar 3, 2024
@whitequark
Copy link
Member

Would from_bits ever need to know the size of the original value?

@wanda-phi
Copy link
Member Author

Would from_bits ever need to know the size of the original value?

It is called on ShapeCastable, which has the length available (since it has to implement as_shape()).

@whitequark
Copy link
Member

Possible naming for LiteralView: lib.data.Const.

@whitequark
Copy link
Member

We have discussed this RFC on the 2024-03-04 weekly meeting. The disposition was to merge, with the following changes:

  • lib.data.LiteralView is renamed to lib.data.Const and made immutable;
  • ShapeCastable.from_bits is allowed to return any type as long as ShapeCastable.const can turn it back into a const-castable value;
    • Additional unresolved question: With the same bit pattern or equivalent bit pattern? This is important if we ever try to roundtrip a NaN through Python's float.
  • lib.data.Layout.const is changed to return a lib.data.Const;
  • Mentioning that instead of mutating a lib.data.Const in simulation, one can set the field directly.

@whitequark whitequark removed the meta:nominated Nominated for discussion on the next relevant meeting label Mar 4, 2024
@wanda-phi wanda-phi changed the title Add an RFC for ShapeCastable.from_bits and LiteralView. Add an RFC for ShapeCastable.from_bits and lib.data.Const. Mar 4, 2024
@whitequark
Copy link
Member

Thank you!

@whitequark whitequark merged commit 953ddfe into amaranth-lang:main Mar 4, 2024
@wanda-phi wanda-phi deleted the literal branch March 4, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core RFC affecting APIs in amaranth-lang/amaranth
Development

Successfully merging this pull request may close these issues.

2 participants