#truth-table #lookup-tables #boolean

volute

Boolean functions implementation, represented as lookup tables (LUT) or sum-of-products (SOP)

11 stable releases

1.1.5 Jun 19, 2024
1.1.4 Jan 12, 2024
1.0.6 Dec 31, 2023
1.0.3 Oct 23, 2023
0.1.1 Aug 17, 2023

#190 in Math

Download history 17/week @ 2024-06-23 2/week @ 2024-06-30 17/week @ 2024-07-07 57/week @ 2024-07-21 21/week @ 2024-07-28 5/week @ 2024-09-15 49/week @ 2024-09-22 20/week @ 2024-09-29 1/week @ 2024-10-06

75 downloads per month
Used in quaigh

MIT/Apache

195KB
5K SLoC

Volute crate Volute documentation Build status

Logic function manipulation using truth tables (LUTs)

The crate implements truth table datastructures, either arbitrary-size truth tables (Lut), or more efficient fixed-size truth tables (Lut2 to Lut12). They provide logical operators and utility functions for analysis, canonization and decomposition. Some support is available for other standard representation, such as Sum-of-Products (Sop).

API and documentation try to follow the same terminology as the C++ library Kitty.

Examples

Create a constant-one Lut with five variables. Check its hexadecimal value.

let lut = Lut::one(5);
assert_eq!(lut.to_string(), "Lut5(ffffffff)");

Create a Lut4 (four variables) which is the logical and of the 1st and 3rd. Check its hexadecimal value.

let lut = Lut4::nth_var(0) & Lut4::nth_var(2);
assert_eq!(lut.to_string(), "Lut4(a0a0)");

Create a random Lut6 (six variables). Display its hexadecimal value.

let lut = Lut6::random();
print!("{}", lut);

Create the parity function on three variables, and check that in can be decomposed as a Xor. Check its value in binary.

let lut = Lut::parity(3);
assert_eq!(lut.top_decomposition(0), DecompositionType::Xor);
assert_eq!(format!("{:b}", lut), "Lut3(10010110)");

Dependencies

~0.2–3.5MB
~36K SLoC