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.
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.
```bash
sudo apt-get install qemu-user
sudo pacman -S qemu-user ```
For more platforms, take a look here.
Then, add ralte32
as a development dependency.
bash
cargo add --dev ralte32
Lastly, create and/or add a short section to your .cargo/config.toml
.
```toml
[target.riscv32imac-unknown-none-elf] rustflags = ['-Ctarget-feature=+crt-static'] runner = "qemu-riscv32 -cpu rv32"
zk
feature:```
Then, to implement some tests, you add an example in examples/
.
```rust,no_run // examples/test-rv32.rs
use ralte32::define_tests;
fn testmultiplication() { asserteq!(6 * 7, 42); }
fn testremainder() { asserteq!(7 % 6, 1); }
definetests!{ testmultiplication, test_remainder, } ```
This can then be ran with:
bash
cargo run --example test-rv32 --target riscv32imac-unknown-none-elf
This will give:
```text Running tests...
Running "testmultiplication"... SUCCESSFUL Running "testremainder"... SUCCESSFUL ```
There are several known limitations.
This project is dual licensed under MIT and APACHE-2.0 licenses.