Crate volute

Source
Expand description

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)");

Modules§

sop
Sum-of-Products representations

Structs§

Lut
Arbitrary-size truth table, representing a N-input boolean function with 2^N bits, one for each input combination
StaticLut
Fixed-size truth table representing a N-input boolean function with 2^N bits; more compact than Lut when the size is known

Enums§

DecompositionType
Basic boolean function families to describe decompositions

Type Aliases§

Lut0
0-input Lut
Lut1
1-input Lut
Lut2
2-input Lut
Lut3
3-input Lut
Lut4
4-input Lut
Lut5
5-input Lut
Lut6
6-input Lut
Lut7
7-input Lut
Lut8
8-input Lut
Lut9
9-input Lut
Lut10
10-input Lut
Lut11
11-input Lut
Lut12
12-input Lut