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

✨ Add support for RISC-V A ISA extension (atomic memory access) #651

Merged
merged 33 commits into from
Jul 22, 2023

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented Jul 21, 2023

This PR provides a first version of the core that supports the RISC-V A ISA extension for atomic memory accesses. The basic idea as well as many of the hardware aspects were triggered by @NikLeberg in #573 (👍).

ℹ️ This is a quite simple/straightforward approach of implementing LR/SC operations. The handling of those operations is done by the memory/bus system instead of the CPU core. More in-depth information can be found at the bottom of this post.

  • Only the load-store (lr.w) and store-conditional (sc.w) instructions are supported. The remaining read-modify-write instructions (like amoswap) are not supported and will raise an illegal instruction exception when executed. However, these unsupported instructions can be emulated using LR/SC combinations. An emulation library for the missing AMO operations and an according test program will be provided.
  • The A extension is enabled via the new CPU_EXTENSION_RISCV_A processor generic.
  • The A instructions are tightly coupled to the memory/bus system of the processor. Besides the CPU-internal logic for executing LR/SC instructions a new bus module ("Reservation Set Control") is added that keeps track of the LR/SC reservation set. (see image below).
  • Right now only a single reservation set is supported. The granularity (= "size") of the reservation set is 4 bytes (1 word) by default, but can be customized via a new processor generic (AMO_RVS_GRANULARITY).

neorv32_bus

More Information

🔍 How do atomic memory accesses / LR/SC combinations work on a hardware level (NEORV32 data sheet)?

💾 How to emulate AMO operations using LR/SC combinations (NEORV32 software framework)?

TODO

The reservation set controller already provides an external interface so other external cores could "snoop" and invalidate the state of the reservation set. However, this interface is not available yet. Maybe this could be integrated into the processor's Wishbone bus... 🤔

increase simulation's IMEM size to 32kB
clean-up & add LR/SC test cases
-> SoC bus request bus: add "is reservation set operation" signal
-> CPU control bus: add "is reservation set operation" signal
@stnolting stnolting self-assigned this Jul 21, 2023
@stnolting stnolting added enhancement New feature or request risc-v compliance Modification to comply with official RISC-V specs. HW hardware-related experimental Experimental feature labels Jul 21, 2023
@stnolting stnolting marked this pull request as ready for review July 21, 2023 20:05
@stnolting stnolting marked this pull request as draft July 21, 2023 20:59
@stnolting stnolting marked this pull request as ready for review July 22, 2023 05:54
@stnolting stnolting merged commit 8779f00 into main Jul 22, 2023
8 checks passed
@stnolting stnolting deleted the riscv_a_extension branch July 22, 2023 05:59
@stnolting
Copy link
Owner Author

FTR

A extension implemented, documented and tested ✔️
Further links and notes added to initial PR description ✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request experimental Experimental feature HW hardware-related risc-v compliance Modification to comply with official RISC-V specs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant