Skip to content

Add an RFC for arbitrary Memory shapes. #40

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 3 commits into from
Jan 22, 2024

Conversation

zyp
Copy link
Contributor

@zyp zyp commented Dec 22, 2023

@zyp zyp force-pushed the arbitrary-memory-shape branch from e93b665 to f4b2423 Compare December 22, 2023 16:28
@whitequark whitequark added meta:nominated Nominated for discussion on the next relevant meeting area:core RFC affecting APIs in amaranth-lang/amaranth labels Dec 22, 2023
@zyp zyp force-pushed the arbitrary-memory-shape branch from f4b2423 to 4a78334 Compare December 22, 2023 17:43
@stafverhaegen-chipflow
Copy link

Would it also be made possible to specify granularity of the WritePort with arbitrary shape ?

@whitequark
Copy link
Member

Would it also be made possible to specify granularity of the WritePort with arbitrary shape ?

I think this should be possible iff the shape is an ArrayLayout.

@zyp
Copy link
Contributor Author

zyp commented Jan 5, 2024

Since we're talking about granularity for write enables and not width conversions, there's not really any need to enforce a uniform element shape, and I'm not sure it's worthwhile to try enforcing that the granularity aligns with natural subdivisions of a shape-castable either. We'd end up with a bunch of special casing for lib.data that's not necessarily even correct.

Consider something like a StructLayout({'a': 1, 'b': 7, 'c': 8, 'd': 16}). Depending on the application, it could make perfect sense to use this with granularity=8 even though some fields are packed together and some fields spans a multiple.

@whitequark
Copy link
Member

whitequark commented Jan 5, 2024

I feel that it's important to not blindly allow a case that results in arbitrarily torn writes. I would say that if you want granularity to be less than the full word, it has to be a Shape and not a shape-castable then. We can always relax this later, but not the other way around, and I think a conservative choice is wise here.

I agree that a dependency on lib.data would be gratuitous here.

@whitequark
Copy link
Member

We have discussed this RFC on the 2024-01-22 weekly meeting. The disposition was to merge with the following changes

  • Memory.width is kept and becomes a read-only wrapper for Shape.cast(self.shape).width;
  • Memory.depth becomes read-only.

There was consensus that allowing granularity to be specified for lib.data.ArrayLayout shapes is desirable, but as Memory currently lives in hdl and not lib this is not possible at the moment.

@zyp Could you please create a tracking issue for this RFC and insert that and the starting date in the RFC text?

@whitequark whitequark removed the meta:nominated Nominated for discussion on the next relevant meeting label Jan 22, 2024
@zyp zyp force-pushed the arbitrary-memory-shape branch from f20a16c to 43ea961 Compare January 22, 2024 19:05
@zyp zyp marked this pull request as ready for review January 22, 2024 19:17
@whitequark whitequark merged commit e10875b into amaranth-lang:main Jan 22, 2024
@zyp zyp deleted the arbitrary-memory-shape branch January 30, 2024 21:28
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.

3 participants