Skip to content
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

MemoryMap should allow adding windows with a larger granularity than the parent #97

Open
zyp opened this issue Jul 17, 2024 · 2 comments

Comments

@zyp
Copy link
Contributor

zyp commented Jul 17, 2024

The data_width attribute of a MemoryMap reflects not the actual data width, but the granularity of the associated bus. A 32-bit bus with byte lanes hence has a memory map with data_width = 8.

MemoryMap.add_window() performs the following check:

        if window.data_width > self.data_width:
            raise ValueError(f"Window has data width {window.data_width}, and cannot be added to a "
                             f"memory map with data width {self.data_width}")

This restriction makes it impossible to add a window without byte lanes (e.g. with granularity 32) to a parent memory map with granularity 8, even if both of the associated buses have an actual data width of 32.

I would like to have a 32-bit wide CSR bus connected to a 32-bit CPU with byte lanes. While the byte lanes are trivial to shim, MemoryMap doesn't support this arrangement, so instead of adding the target memory map as a window, I have to work around it by copying and transforming each individual resource entry to a new memory map.

Example implementation of a simple granularity converter that silently ignores writes smaller than the target granularity: https://paste.jvnv.net/view/g35PB

@jfng
Copy link
Member

jfng commented Jul 30, 2024

I think we should add a granularity parameter to csr.Signature instead, which becomes the data_width of the MemoryMap. The data_width of csr.Signature would be restricted to multiples of granularity.

@zyp
Copy link
Contributor Author

zyp commented Jul 30, 2024

The issue is not strictly limited to CSR buses. You'll run into the same issue any time you would like to attach a target without byte lanes to an initiator with byte lanes. E.g. third party IP cores with memory mapped IO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants