Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

lschuermann
Copy link
Member

@lschuermann lschuermann commented Dec 20, 2020

Pull Request Overview

This pull request

  • updates the targeted LiteX revision for both boards (litex/sim and litex/arty)

  • points to a companion repository (tock-litex), which contains prebuilt bitstreams and build scripts for generating these

    The board definitions in this repository are tested against bitstreams obtained by these build scripts, so it makes sense to publish the bitstreams themselves as well.

  • changes the LiteX boards to require the "Secure" / "TockSecureIMC" VexRiscv CPU variant containing a PMP and enables PMP support in the litex_vexriscv chip crate

    "TockSecureIMC" is a custom VexRiscv CPU configuration which has support for PMP, hardware multiplication and compressed instructions. It significantly reduces code size and should improve performance. The patch to the upstream pythondata-cpu-vexriscv can be found here. Prebuilt Verilog-files and complete bitstreams are published as part of the tock-litex repository releases.

Testing Strategy

This pull request was tested by running the mpu test app with all test cases on both the Arty A7 35T and the Verilated simulation.

TODO or Help Wanted

I don't think it's very elegant to point to some outside repository for the generated bitstreams. It might be more trustworthy to have this repository under the Tock GitHub organization, given that we already have the Community GitHub team. I'd be open to moving it, but also fine if it stays in the current location.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

Acknowledgements

A huge thanks to @lindemer for contributing PMP support to VexRiscv. This must have been a lot of work.

I was also impressed by the PMP infrastructure in Tock. Everything worked flawlessly on the first try. Thanks to @bradjc, @alistair23 and all other contributors!

@lschuermann lschuermann added the arch/risc-v RISC-V architecture label Dec 20, 2020
@lindemer
Copy link

Great to hear the hardware works, tag me if you find any bugs 🎅

This changes the LiteX-ArtyA7 board to use a custom VexRiscv CPU with
physical memory protection, hardware multiplication and compressed
instruction support.

This allows Tock to use the available Rust target architecture
"riscv32imc", utilizing the hardware multiplication and compressed
instruction support of the CPU.
@lschuermann lschuermann force-pushed the dev/litex-vexriscv-pmp branch from 663292d to e23e2aa Compare December 22, 2020 14:37
@lschuermann
Copy link
Member Author

Since this PR is still open, I've also switched litex/arty to a softcore which has a PMP, along with hardware multiplication and compressed instruction support. This significantly reduces the code size requirements and should have increased performance.

The "TockSecureIMC" VexRiscv variant is however not contained upstream. I've documented (in the README) where to obtain the patch to pythondata-cpu-vexriscv to build this CPU's Verilog. Furthermore, the generated Verilog artifacts and the complete bitstream is provided in a release of the tock-litex companion repository, as documented.

The Verilated LiteX simulation (litex/sim) is not switched to riscv32imc yet, as I'm not yet sure how to provide a pre-built Verilated simulation binary from tock-litex and I don't want to force anyone to use the Nix package manager to run Tock on these boards (or simulations).

@lschuermann lschuermann changed the title litex: update LiteX revision, use "Secure" cpu variant and integrate PMP litex: update LiteX revision, use "Secure"/"TockSecureIMC" cpu variant and integrate PMP Dec 22, 2020
@lschuermann
Copy link
Member Author

Given this got one approval, I'd raise the question again whether it'd be a good idea to move lschuermann/tock-litex to the Tock GitHub organisation, given that I point to this repository in the README and we rely on a softcore CPU configuration defined in there.

@bradjc
Copy link
Contributor

bradjc commented Jan 4, 2021

Given this got one approval, I'd raise the question again whether it'd be a good idea to move lschuermann/tock-litex to the Tock GitHub organisation, given that I point to this repository in the README and we rely on a softcore CPU configuration defined in there.

I don't see a need to do this, as we generally consider hardware to be outside of Tock and maintained by someone else.

build infrastructure in
[pythondata-cpu-vexriscv](https://github.com/litex-hub/pythondata-cpu-vexriscv),
using a
[patch](https://github.com/lschuermann/tock-litex/blob/master/pkgs/pythondata-cpu-vexriscv/0001-Add-TockSecureIMC-cpu-variant.patch)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this patch be upstreamed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there might be a chance of getting this CPU configuration upstreamed in the pythondata-cpu-vexriscv, but based on my understanding this repository is simply a default collection of some variants anyways. When you're building some hardware / gateware, or targeting some hardware from an OS, it'd be expected for you to build some custom CPU meeting these requirements anyways. For people who don't feel like using Scala to build it, I upload the patched & built pythondata-cpu-vexriscv along with every release.

@lschuermann
Copy link
Member Author

I don't see a need to do this, as we generally consider hardware to be outside of Tock and maintained by someone else.

Sounds good. Thanks for the clarification!

@bradjc bradjc added the last-call Final review period for a pull request. label Jan 6, 2021
@bradjc
Copy link
Contributor

bradjc commented Jan 7, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 7, 2021

@bors bors bot merged commit 2606380 into tock:master Jan 7, 2021
@lschuermann lschuermann deleted the dev/litex-vexriscv-pmp branch January 16, 2021 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch/risc-v RISC-V architecture last-call Final review period for a pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants