🧱 physdes-rs
physdes-rs is a Rust library for VLSI physical design operations, providing efficient geometric data structures and algorithms for electronic design automation (EDA).
📚 Table of Contents
✨ Features
- Points & Vectors: Generic 2D point and vector operations with type-safe arithmetic
- Intervals: Efficient range operations and interval algebra
- Polygons: Arbitrary polygon support with area calculation and convex hull
- Rectilinear Polygons: Optimized algorithms for Manhattan geometry
- VLSI Operations: Specialized operations for circuit layout and physical design
- Generic Types: Support for multiple numeric types (i32, f64, etc.)
- No-std Support: Can be used in embedded environments (with
--no-default-features)
🛠️ Installation
📦 Cargo
Add this to your Cargo.toml:
[]
= "0.1"
Or install the binary:
🚀 Quick Start
Creating and Manipulating Points
use Point;
// Create a point
let p = new;
// Access coordinates
println!;
// Arithmetic operations with vectors
use Vector2;
let v = new;
let p2 = p + v;
// Comparison operations
let p3 = new;
assert!;
Working with Intervals
use Interval;
// Create intervals
let interval_a = new;
let interval_b = new;
// Check overlap
assert!;
// Compute intersection
let intersection = interval_a.intersect;
assert_eq!;
// Check containment
assert!;
Creating and Analyzing Polygons
use Polygon;
use Point;
// Create a square polygon
let points = vec!;
let polygon = new;
// Calculate area
let area = polygon.area;
assert_eq!;
// Check if polygon is convex
assert!;
// Get bounding box
let bbox = polygon.bounding_box;
Vector Operations
use Vector2;
// Create vectors
let v1 = new;
let v2 = new;
// Vector arithmetic
let sum = v1 + v2;
let diff = v1 - v2;
let scaled = v1 * 2;
// Dot product and cross product
let dot = v1.dot;
let cross = v1.cross;
// Vector magnitude
let magnitude = v1.norm;
📖 API Overview
Core Types
| Type | Description | Module |
|---|---|---|
Point<T1, T2> |
2D point with x and y coordinates | point |
Vector2<T1, T2> |
2D vector with x and y components | vector2 |
Interval<T> |
Range [lb, ub] with interval algebra | interval |
Polygon<T> |
Arbitrary polygon | polygon |
RPolygon<T> |
Rectilinear (Manhattan) polygon | rpolygon |
MergeObj<T1, T2> |
Merge object for combining intervals | merge_obj |
Key Operations
Point Operations
- Arithmetic:
+,-,+=,-=with vectors - Comparison:
==,!=,<,> - Distance:
dist_to(),dist_to_point() - Overlap:
overlaps(),contains() - Convex hull:
convex_hull()
Vector Operations
- Arithmetic:
+,-,*,/with scalars - Dot product:
dot() - Cross product:
cross() - Norm:
norm(),norm_squared() - Normalization:
normalize()
Interval Operations
- Overlap:
overlaps(),contains() - Set operations:
intersect(),convex_hull() - Properties:
length(),is_empty()
Polygon Operations
- Properties:
area(),is_convex(),orientation() - Bounding:
bounding_box() - Validation:
is_valid(),is_rectilinear()
💡 Use Cases
1. Circuit Layout Design
use ;
// Define circuit component as a rectangle
let component = new;
// Calculate placement constraints
let x_range = new;
let y_range = new;
2. Floorplanning
use RPolygon;
// Create rectilinear polygon for floorplan
let floorplan = from_rectangle;
// Check for overlaps with other modules
let module_a = from_rectangle;
3. Wire Routing Analysis
use ;
// Calculate Manhattan distance for routing
let start = new;
let end = new;
let wire_length = .abs + .abs;
4. Design Rule Checking (DRC)
use ;
// Check minimum spacing rules
let component_a = new;
let component_b = new;
let min_spacing = 3;
let spacing = component_b.lb - component_a.ub;
assert!;
⚡ Performance
The library is designed for performance:
- Generic over numeric types: Choose between
i32,i64,f32,f64based on your needs - Efficient algorithms: Optimized for VLSI design workloads
- No allocations: Core operations use stack allocation where possible
- SIMD-ready: Structured to enable future SIMD optimizations
Benchmarks
Run benchmarks with:
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Development Setup
# Clone the repository
# Run tests
# Run clippy
# Format code
# Run benchmarks
📜 License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
🙏 Acknowledgments
Built with Rust, designed for VLSI physical design applications.
🔗 Related Projects
Polyglot Implementations
- physdes-cpp - C++ version
- physdes-py - Python version
Algorithm Polyglot
- algorithm-polyglot - Meta-repo documenting the polyglot strategy