Skip to main content

ab_riscv_primitives/
lib.rs

1//! Composable RISC-V primitives (instructions, registers) and abstractions around them.
2//!
3//! The primitives are designed to be generic over the number of general purpose registers, and a
4//! macro system allows composing base ISA like RV32/RV64 with a desired set of standard or custom
5//! extensions/instructions. Trait abstractions are designed to allow expressing generic APIs
6//! without hardcoding specific types whenever possible.
7//!
8//! The immediate needs dictate the current set of available instructions and extensions. Consider
9//! contributing if you need something not yet available.
10//!
11//! `ab-riscv-interpreter` crate contains a complementary interpreter implementation, but these
12//! primitives are completely independent.
13//!
14//! `ab-riscv-act4-runner` crate in the repository contains a complementary RISC-V Architectural
15//! Certification Tests runner for <https://github.com/riscv-non-isa/riscv-arch-test> that ensures
16//! correct implementation.
17//!
18//! Does not require a standard library (`no_std`) or an allocator.
19//!
20//! ## Supported ISA variants and extensions
21//!
22//! ISA variants:
23//! * RV32I (version 2.1)
24//! * RV32E (version 2.0)
25//! * RV64I (version 2.1)
26//! * RV64E (version 2.0)
27//!
28//! Extensions:
29//! * M (version 2.0)
30//! * B (version 1.0.0)
31//! * Zba (version 1.0.0)
32//! * Zbb (version 1.0.0)
33//! * Zbc (version 1.0.0)
34//! * Zbkb (version 1.0.1)
35//! * Zbkc (version 1.0.1)
36//! * Zbkx (version 1.0.1)
37//! * Zbs (version 1.0.0)
38//! * Zca (version 1.0.0)
39//! * Zcb (version 1.0.0)
40//! * (experimental) Zcmp (version 1.0.0)
41//! * Zkn (version 1.0.1)
42//! * Zknd (version 1.0.1)
43//! * Zkne (version 1.0.1)
44//! * Zknh (version 1.0.1)
45//! * Zicond (version 2.0)
46//! * Zicsr (version 2.0)
47//! * (experimental) Zve32x (version 1.0.0)
48//! * (experimental) Zve64x (version 1.0.0)
49//! * (experimental) Zvl*b (version 1.0.0), where `*` is anything allowed by the specification
50//!
51//! All extensions except experimental pass all relevant RISC-V Architectural Certification Tests
52//! (ACTs) using the ACT4 framework.
53//!
54//! Any permutation of compatible extensions is supported.
55//!
56//! Experimental extensions are known to have bugs and need more work. They are not tested against
57//! ACTs yet.
58
59#![no_std]
60#![feature(
61    const_cmp,
62    const_convert,
63    const_default,
64    const_destruct,
65    const_ops,
66    const_option_ops,
67    const_trait_impl,
68    const_try,
69    const_try_residual,
70    generic_const_exprs,
71    stmt_expr_attributes,
72    try_blocks
73)]
74#![expect(incomplete_features, reason = "generic_const_exprs")]
75
76pub mod instructions;
77pub mod prelude;
78pub mod privilege;
79pub mod registers;