csa-rhdl 0.1.0

Carry-save adder compressor trees composed via comp-cat-rs, with hdl-cat backend
Documentation
//! Passthrough accumulator for `M ∈ {0, 1, 2}`.
//!
//! When the input bundle count is already `≤ 2`, the compressor
//! tree has no work to do; we wire the input straight through.

use crate::category::arrow::CircuitArrow;
use crate::shape::Shape;

/// The passthrough arrow for a small bundle count.
#[must_use]
pub const fn sum_terms_passthrough(m: usize, w: usize) -> CircuitArrow {
    CircuitArrow::passthrough(Shape::new(m, w))
}

#[cfg(test)]
mod tests {
    use super::sum_terms_passthrough;
    use crate::shape::Shape;

    #[test]
    fn passthrough_preserves_shape() {
        let a = sum_terms_passthrough(2, 16);
        assert_eq!(a.source(), Some(Shape::new(2, 16)));
        assert_eq!(a.target(), Some(Shape::new(2, 16)));
    }
}