RALTE32
Crates.io | Docs.rs | Repository
A Rust Arithmetic Library Testing Environment for embedded RISC-V 32-bit. This libraries allows the testing of arithmetic Rust code made for RISC-V 32-bit using the QEMU simulator. This is especially useful when developing with the Rust riscv32 intrinsics.
This library is mostly just a minimal hack to implement a testing environment
and port the riscv32 embedded targets to a Linux userspace target.
Usage
First, this project uses the QEMU userspace simulator to simulate the target
code. This can be installed with the standard qemu-user package on most
operating systems.
# Linux: Debian / Ubuntu
# Linux: ArchLinux
For more platforms, take a look here.
Then, add ralte32 as a development dependency.
Lastly, create and/or add a short section to your .cargo/config.toml.
# ...
[]
= ['-Ctarget-feature=+crt-static']
= "qemu-riscv32 -cpu rv32"
# NOTE: If you want to enable additional target features, add them here.
#
# Example to enable the `zk` feature:
# rustflags = ['-Ctarget-feature=+crt-static,+zk']
# runner = "qemu-riscv32 -cpu rv32,zk=true"
Then, to implement some tests, you add an example in examples/.
// examples/test-rv32.rs
use define_tests;
define_tests!
This can then be ran with:
This will give:
Running tests...
Running "test_multiplication"... SUCCESSFUL
Running "test_remainder"... SUCCESSFUL
Limitations
There are several known limitations.
- First test or assert to fail, stops the test environment.
- This only tests user-level code. Access to supervisor, machine or hypervisor instructions and CSRs is not possible.
- Very limited support for printing.
License
This project is dual licensed under MIT and APACHE-2.0 licenses.