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

mmap: Add write functionality #70

Merged
merged 5 commits into from
Jul 31, 2024
Merged

Conversation

m-byte
Copy link
Contributor

@m-byte m-byte commented Jun 7, 2024

With this change, it is possible to memory map e.g. PSRAM. When setting with_write to "csr", it can also be used to support faster flash writing via etherbone. For flash, only False and "csr" should be used, as the some other logic or application needs to make sure that the flash is erased ahead of time. True is only meant for use with RAM chips.

There are two bugs that this also addresses:

  1. Addresses are now masked to flash size or addr_width if no size is set. I'm not 100% happy with this solution, as it might cause issues with non power of 2 flashes (do those exist). However, without this, I would get flash writes to the wishbone address rather than offsets inside the flash. So I'm open to better alternatives. Optimum would be subtracting the base bus address, but I haven't found any clean way of accessing it. I found a way to wire the origin through, so now this can be fixed by wiring through the corresponding addresses (described in the commit message and I will create a PR for LiteX, once this is merged)
  2. In quad mode the core was driving all pins for the duration of the dummy bits. Now, the pins are released at the start of the dummy period to not interfere with the pins being driven by the external chip.

Let me know if they should be part of separate commits/ PRs.

Currently, tests are still to be added.

This should fix #25

@m-byte
Copy link
Contributor Author

m-byte commented Jun 7, 2024

@enjoy-digital should the CSR functionality also be tested? If so, is there any recommended approach?

@m-byte m-byte force-pushed the psram branch 2 times, most recently from 103acba to 4840368 Compare June 8, 2024 16:37
With this change, it is possible to memory map e.g. PSRAM. When setting
with_write to "csr", it can also be used to support faster flash writing
via etherbone. For flash, only False and "csr" should be used, as the
some other logic or application needs to make sure that the flash is
erased ahead of time. True is only meant for use with RAM chips.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
With this change, it is possible compensate the memory map origin using offset.

E.g. for spi flash, the following line would suffice
`self.comb += self.spiflash_core.mmap.offset.eq(self.bus.regions.get(name, None).origin)`

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
This change prevents accidental shorts during the wait period in QSPI,
as the SoC should not be driving data lines while waiting for the memory
chip to get ready.

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
Add a minimal test for mmap write

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
@m-byte m-byte marked this pull request as ready for review June 8, 2024 16:50
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
@m-byte
Copy link
Contributor Author

m-byte commented Jul 31, 2024

@enjoy-digital do you think you would find some time to review this soon?

@enjoy-digital
Copy link
Member

@m-byte: Thanks for the PR and sorry for the delay...! I'll review it before the end of the week.

Copy link
Member

@enjoy-digital enjoy-digital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @m-byte, this make sense and the code look fine, let's merge. Thanks also for the test-bench, really appreciated and help a lot for future maintenance!

@enjoy-digital enjoy-digital merged commit 6ac3884 into litex-hub:master Jul 31, 2024
1 check failed
@m-byte
Copy link
Contributor Author

m-byte commented Jul 31, 2024

Thank you!

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

Successfully merging this pull request may close these issues.

Support the SPI RAM found on HAD badge
3 participants