https://github.com/coloquinte/volute
Implementation of logic function as lookup tables and sum of products
https://github.com/coloquinte/volute
Last synced: about 1 month ago
JSON representation
Implementation of logic function as lookup tables and sum of products
- Host: GitHub
- URL: https://github.com/coloquinte/volute
- Owner: Coloquinte
- License: apache-2.0
- Created: 2023-04-30T17:05:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-19T15:06:10.000Z (11 months ago)
- Last Synced: 2024-12-20T23:14:19.802Z (5 months ago)
- Language: Rust
- Homepage: https://docs.rs/volute/
- Size: 128 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
- Citation: CITATION.cff
Awesome Lists containing this project
README
[](https://crates.io/crates/volute)
[](https://docs.rs/volute)
[](https://github.com/Coloquinte/volute/actions/workflows/build.yml)Logic function manipulation using truth tables (LUTs)
The crate implements truth table datastructures, either arbitrary-size truth tables
([`Lut`](https://docs.rs/volute/latest/volute/struct.Lut.html)), or more efficient
fixed-size truth tables ([`Lut2` to `Lut12`](https://docs.rs/volute/latest/volute/struct.StaticLut.html)).
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`](https://docs.rs/volute/latest/volute/sop/struct.Sop.html)).API and documentation try to follow the same terminology as the C++ library [Kitty](https://libkitty.readthedocs.io/en/latest).
# Examples
Create a constant-one Lut with five variables.
Check its hexadecimal value.
```rust
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.
```rust
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.
```rust
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.
```rust
let lut = Lut::parity(3);
assert_eq!(lut.top_decomposition(0), DecompositionType::Xor);
assert_eq!(format!("{:b}", lut), "Lut3(10010110)");
```