| Crates.io | espresso-logic |
| lib.rs | espresso-logic |
| version | 3.1.2 |
| created_at | 2025-11-06 13:13:05.192341+00 |
| updated_at | 2025-11-12 12:55:47.615774+00 |
| description | Rust bindings for the Espresso heuristic logic minimizer (UC Berkeley) |
| homepage | |
| repository | https://github.com/marlls1989/espresso-logic |
| max_upload_size | |
| id | 1919665 |
| size | 4,616,689 |
Rust bindings to the Espresso heuristic logic minimiser from UC Berkeley, with a modern high-level API for Boolean function minimisation.
Espresso takes Boolean functions and produces minimal or near-minimal equivalent representations. This Rust crate provides safe, thread-safe bindings with modern features:
expr! macro, supporting both mathematical (*, +) and logical (&, |) notationAdd to your Cargo.toml:
[dependencies]
espresso-logic = "3.1"
use espresso_logic::{BoolExpr, expr};
fn main() -> std::io::Result<()> {
// Build expression with redundant terms
let redundant = expr!("a" * "b" + "a" * "b" * "c");
println!("Original: {}", redundant);
// Minimise it
let minimised = redundant.minimize()?;
println!("Minimised: {}", minimised); // Output: a * b
Ok(())
}
use espresso_logic::{Cover, CoverType};
fn main() -> std::io::Result<()> {
// Create a cover for XOR function
let mut cover = Cover::new(CoverType::F);
// Add cubes: output is 1 when inputs differ
cover.add_cube(&[Some(false), Some(true)], &[Some(true)])?; // 01 -> 1
cover.add_cube(&[Some(true), Some(false)], &[Some(true)])?; // 10 -> 1
let minimised = cover.minimize()?;
println!("Minimised to {} cubes", minimised.num_cubes());
Ok(())
}
Note: Covers support multi-output functions, don't-care optimisation, and PLA file I/O.
Choose the right API for your use case:
Use when you need to:
expr! macrouse espresso_logic::{BoolExpr, expr, Minimizable};
let xor = expr!("a" * !"b" + !"a" * "b");
let minimised = xor.minimize()?;
Use when you need to:
use espresso_logic::{Cover, CoverType};
let mut cover = Cover::new(CoverType::FD); // with don't-cares
cover.add_cube(&[Some(true), None], &[Some(true)])?; // 1- -> 1
Use the espresso module directly when you need:
See the espresso module documentation for details.
Prerequisites: Rust 1.70+, C compiler, libclang
# macOS
xcode-select --install
# Ubuntu/Debian
sudo apt-get install build-essential libclang-dev
See docs/INSTALLATION.md for detailed platform-specific instructions.
Install the optional CLI:
cargo install espresso-logic --features cli
Usage:
espresso input.pla > output.pla
espresso -s input.pla # Show statistics
See docs/CLI.md for more options.
Run included examples:
cargo run --example boolean_expressions
cargo run --example xor_function
cargo run --example pla_file
cargo run --example concurrent_transparent
See docs/EXAMPLES.md for comprehensive code examples.
cargo test
See TESTING.md for comprehensive testing documentation.
Contributions welcome! See CONTRIBUTING.md for guidelines.
This project contains three layers of licensed work:
See LICENSE and ACKNOWLEDGMENTS.md for details.
Espresso was developed by Robert K. Brayton and his team at UC Berkeley. Special thanks to the original developers and Sébastien Cottinet for the modernized C version.
If you use this library in academic work, please cite:
@article{brayton1984logic,
title={Logic minimization algorithms for VLSI synthesis},
author={Brayton, Robert K and Hachtel, Gary D and McMullen, Curtis T and Sangiovanni-Vincentelli, Alberto L},
journal={Kluwer Academic Publishers},
year={1984}
}
Made with ❤️ for the Rust and digital logic communities.