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

CSR ordering support in generated files #1921

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AndrewD
Copy link
Collaborator

@AndrewD AndrewD commented Apr 9, 2024

Add CSR_ORDERING constants and update access functions. Unchanged behaviour with default csr_ordering="big".

Can use --csr-ordering little on command line or parser.set_defaults(csr_ordering="little").

Note that this only affects the addressing of CSR that are 64bit or wider.

This is a proof of concept implementation - only confirmed by inspection so far.

Andrew Dennison added 2 commits April 22, 2024 11:42
csr_ordering default is "big" but there was no way for software
to detect if csr_ordering was changed to "little" to match the cpu.
csr_ordering default is "big" but there was no way for software
to detect if csr_ordering was changed to "little" to match the cpu.
@trabucayre
Copy link
Collaborator

Hi,
I have updated/rebased/squashed this PR here.

What is your objective? I'm agree highest word is by default written in lowest address but it seems coherent with CSR policy?
using little and big seems confusing because for endianness this at Byte level and this may add some issue with kernel.

@AndrewD
Copy link
Collaborator Author

AndrewD commented May 31, 2024

This only affects the way csr longer than 32bits work. Currently those csr are ordered big endian on little endian (by default) CPUs like riscv.

For example:

  • add a field to the end an existing csr that results in a > 32 bit CSR. The word for the new field is placed first so the binary API of the peripheral changes. This resulted in a bug to track down and is just not intuitive to me: a longer csr should be compatible (but will still shift subsequent csr).
  • 64 bit values such as the dma address for sdcard need the words to be written in non-native order resulting in ugly code in Linux/nuttx drivers.

Does this help clarify the intention?

@AndrewD
Copy link
Collaborator Author

AndrewD commented May 31, 2024

updated/rebased/squashed this PR here.

Thanks! I looked at rebasing this yesterday but decided to leave it until later due to the conflicts.

@AndrewD
Copy link
Collaborator Author

AndrewD commented May 31, 2024

Also note that by default this has no effect on the generated gateware, but it will be require driver changes if the csr_ordering is changed.
I have a separate change that adds the correct information to device tree so the Linux SD card driver could support both options.

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.

None yet

2 participants