Skip to content

fpetrot/128-bit-riscv-devs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,029 Commits
 
 
 
 
 
 
 
 

Repository files navigation

128-bit RISC-V GNU Cross Development Environment, QEMU Cross Emulation, and Hardware support in CVA6

This repo contains the necessary stuff to built a 128-bit RISC-V GNU Cross Development Environment, execute the resulting programs on QEMU and a 128-bit CVA6 RTL design. It support, with bugs, the usual cross-development tools and allows to compile and test simple bare metal programs for now.

This was a kind of a fork of https://github.com/riscv-collab/riscv-gnu-toolchain done in May/July 2022. But now that almost all riscv specific stuff has been upstreamed, there is no clear reason to (try to) maintain this stuff that is in essence a set of moving pointers.

To make things easier (...) it is now under the form of a docker file that fetches the rights repositories and builds the whole stuff. This is necessary because the binutils require specific versions for the autotools (documented in binutils README-maintainer-mode) when building from scratch. All tools sources are kept after building, since this docker is meant to be used for active development.

The docker image contains also a native gdb since there are still many bugs floating around, along with vim and a base configuration file, so you might get started quickly. Note that bash is configured in vi mode, so you can remember what life was before the internet.

For gcc, available ABI options are llp128, llp128f, llp128d. 128-bit support is experimental, known issues are:

  • soft floating point operations have erratic behaviour, support for 128-bit words is not done
  • hard floating points moves (fmv) are currently seen as illegal by qemu (I believe I patched this but I am not sure anymore)
  • linux configuration is not supported
  • musl configuration is not supported

Seems useful to compile with:

  • -mcmodel=medany to avoid overflow on the 20-bit offsets used here and there, but this is true independently of the 128-bit xlen
  • -fno-builtin when using optimization as we did not handle well the memcpy and memset builtins, and weird behavior occurs when they are used

We defined an elf128 format that is documented in the elf128-spec.md file.

We also include our QEMU support for elf128, as although we upstreamed (thanks to the QEMU riscv and tcg maintainers) the 128-bit instructions support, vanilla QEMU still lives with elf64 as the natural executable format even for 128-bit executables. The elf128 branch of our QEMU fork parses the elf128 format we defined and that is generated by this toolchain and sends gdb the proper information for debugging 128-bit executables too.

In addition, we use specific RV128 opcodes, as defined in the riscv_opcodes.txt file. This list is originally from the repository of Micheal Clark. Because there is an opcode collision between the lq instruction from RV128I and CBO instructions from the CMO extension when the rd field is zero, we add the constraint that rd in lq must be different from zero.

All of that is within the docker, along with our 128-bit unit tests. Check the makefiles and qemu invocation there for examples.

Building and using the docker image

$ docker build . -t rv128
$ docker run --name dev128 -tid rv128 bash
$ docker attach dev128 #or docker exec -it dev128 bash
# And if you need several shells in the container, with, e.g. tmux
$ docker exec -it dev128 bash

scp is available, so you can copy from the host your .gitconfig and .ssh directories to access the git repos at will. This is not the recommended use of docker, but I find it pretty adapted to the need.

Structure of the container

  • 128-test (dev/128) : a set of tests
  • cva6 (dev/128) : a 128-bit version of the CVA6 RISC-V CPU
  • newlib (dev/128) : a 128-bit version of the newlib libc (included in our compiler)
  • qemu-riscv128 (dev/128) : a version of qemu supporting the elf128 format
  • riscv-binutils (dev/128) : a 128-bit version of binutils
  • riscv-gcc (dev/128) : a 128-bit version of gcc
  • riscvbareapps (main) : some examples to use riscvbarelib
  • riscvbarelib (dev/128) : a small footprint syscall library to use with newlib
  • rv128_ariane_testharness : contains a Makefile generated by riscvbarelib that can be used to compile a code

Main contributors

I would like to thanks my beloved students at Ensimag that choose to do their 2A (bachelor level) intership at TIMA on these subjects, without their help the project would struggle even more to survive!

In particular, I'd like to acknowledge the work of:

  • Fabien Portas (2020), that contributed to supporting 128-bit in QEMU, basis on which I build the upstreamed patches, thanks to the QEMU community for its open state of mind
  • Sylvain Noiry (2022), who did the work on gcc and the binutils, with no hope whatsover to be upstreamed
  • Liam-Angelo Giono (2025), who took over the binutils, made the newlib port, and added tests
  • Pierre Humblot (2025), that worked on the 128-bit CVA6 that is now part of the Docker, and who worked with Liam-Angelo to add tests and port them on the RTL

I would also like to acknowledge the financial support of the French Agence Nationale de la Recherche under grant ANR-21-CE25-0016 (Maplurinium project).

Optimistic Quote

"We might never build 128-bit computers, but it would probably be good to invent a notation for 128-bit integers, whose generated code on 64-bit CPUs is about the same as 64-bit code is on 32-bit CPUs. It would be nice to do that long before it is really needed. In general, predictable long-term problems are most efficiently solved with a little planning, not with frenzied efforts when the problem is imminent. Fortunately, 128-bitters are many years away, if ever (maybe 2020–2040), because we’ve just multiplied our addressing size by four billion, and that will last a while, even if Moore’s Law continues that long! In case 128-bit happens in 2020, however, it would be wise to be thinking about the next integer size around 2010"

John Mashey. "The long road to 64 bits." Communications of the ACM 52.1 (2009): 45-53.

About

Fork of the riscv-gnu-toolchain supporting the 128-bit extension

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors