Espresso Logic Minimizer
A powerful Rust library for minimizing Boolean functions using the classic Espresso heuristic logic minimizer from UC Berkeley.
Why Espresso Logic?
Espresso takes a Boolean function represented as a sum-of-products and produces a minimal or near-minimal equivalent representation. This Rust crate provides safe, idiomatic bindings with modern features.
Key Contributions:
- Thread-Safe Execution - The original Espresso C code used global state, making concurrent execution unsafe. This crate implements C11 thread-local storage for all globals, enabling safe parallel minimization across threads.
- Safe Rust API - Memory-safe wrappers with proper resource management
- Modern Features - Boolean expression parsing, operator overloading, and procedural macros
Perfect for:
- Digital logic synthesis and optimization
- PLA (Programmable Logic Array) minimization
- Boolean function simplification in CAD tools
- Concurrent logic minimization in multi-threaded applications
- Teaching Boolean algebra and logic design
- Research in logic optimization
β¨ Features
- Thread-Safe Concurrent Execution - Unlike original Espresso, safely run minimization in parallel threads via C11 thread-local storage
- Safe Rust API - Memory-safe wrappers with zero-cost abstractions
- Boolean Expressions - High-level API with parsing, operator overloading, and
expr!macro - PLA File Support - Read and write Berkeley PLA format files
- Minimal Dependencies - Core library uses only
libcandlalrpop-util - Command Line Tool - Compatible with original Espresso CLI (optional)
- Well Documented - Comprehensive API documentation and examples
π Quick Start
Add this to your Cargo.toml:
[]
= "3.0"
Simple Example
use ;
Working with Variables
use ;
π Common Use Cases
Truth Table Minimization
use ;
Multiple Outputs
use ;
PLA Files
use ;
π― API Overview
This crate provides two API levels to suit different needs:
High-Level API (Recommended)
Use BoolExpr and Cover for most applications:
- β Thread-safe by design - No manual synchronization needed
- β Automatic memory management - RAII handles cleanup
- β
Clean syntax -
expr!macro and operator overloading - β Dynamic dimensions - Automatic dimension management
- β Easy to use - Idiomatic Rust API
Perfect for:
- Application development
- Logic synthesis tools
- Educational projects
- Rapid prototyping
Low-Level API (Advanced)
Direct espresso::Espresso and espresso::EspressoCover access for specialized needs:
- π Access to intermediate covers - Get ON-set (F), don't-care (D), OFF-set (R) separately
- π― Custom don't-care/off-sets - Provide your own D and R covers for optimization
- β‘ Maximum performance - ~5-10% faster than high-level API, minimal overhead
- π§ Explicit instance control - Manually manage Espresso instance lifecycle
Use when you need:
- Access to all three covers (F, D, R) from minimization
- To provide custom don't-care or off-set covers
- Absolute maximum performance (5-10% speedup)
- Explicit control over instance creation/destruction
Note: Algorithm configuration via EspressoConfig works with both APIs -
if you only need to tune algorithm parameters, use the high-level
Cover::minimize_with_config() instead.
β οΈ Important Constraints:
- All covers on a thread must use the same dimensions until dropped
- Requires manual dimension management
- More complex error handling
use ;
use EspressoConfig;
See docs/API.md for complete API documentation and the espresso module documentation for detailed safety guidelines.
π οΈ Command Line Usage
Install the CLI tool (optional):
Basic usage:
# Minimize a PLA file
# Show statistics
# Exact minimization (slower but optimal)
See docs/CLI.md for more options.
π¦ Installation
Prerequisites
- Rust 1.70 or later
- C compiler (gcc, clang, or msvc)
- libclang (for bindgen during build)
macOS:
Ubuntu/Debian:
Windows: Install Visual Studio Build Tools with C++ support
See docs/INSTALLATION.md for detailed platform-specific instructions.
π Examples
Run included examples to see different features:
# Boolean expressions
# XOR minimization
# PLA file processing
# Concurrent execution
See docs/EXAMPLES.md for comprehensive code examples.
π Documentation
- API Reference - Complete API documentation
- Examples Guide - Comprehensive usage examples
- Boolean Expressions - Expression API details
- CLI Guide - Command-line usage
- Installation - Platform-specific setup
- Testing Guide - How to run tests
- Contributing - How to contribute
π§ͺ Testing
For comprehensive testing including memory safety and regression tests, see TESTING.md.
π Compatibility
- Rust: 1.70+
- Platforms: Linux, macOS, Windows
- Espresso Version: 2.3 (01/31/88)
π€ Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
π References
π License
This project contains three layers of licensed work:
- Original Espresso: UC Berkeley (permissive license)
- Modernized C Code: SΓ©bastien Cottinet (MIT)
- Rust Wrapper: Marcos Sartori (MIT)
See LICENSE and ACKNOWLEDGMENTS.md for details.
π Acknowledgments
Espresso was developed by Robert K. Brayton and his team at UC Berkeley. Special thanks to:
- The original Espresso developers (Brayton, Hachtel, McMullen, Sangiovanni-Vincentelli)
- SΓ©bastien Cottinet for the MIT-licensed modernized C version
- The Rust community for excellent FFI tools
For complete acknowledgments, see ACKNOWLEDGMENTS.md.
π Citation
If you use this library in academic work, please cite:
π Related Projects
π¬ Support
- π Report a bug
- π‘ Request a feature
- π View documentation
- π¬ Ask a question
Made with β€οΈ for the Rust and digital logic communities.