csa-rhdl 0.1.0

Carry-save adder compressor trees composed via comp-cat-rs, with hdl-cat backend
Documentation
//! Shape: the object type in the circuit category.
//!
//! A [`Shape`] pairs a bundle count with a per-bundle bit width.
//! Shapes are the categorical objects; morphisms between shapes
//! are combinational circuits.

/// The shape of a signal bundle: `bundles` wires each of `width` bits.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Shape {
    bundles: usize,
    width: usize,
}

impl Shape {
    /// Construct a shape from its two coordinates.
    ///
    /// # Examples
    ///
    /// ```
    /// use csa_rhdl::shape::Shape;
    /// let s = Shape::new(9, 16);
    /// assert_eq!(s.bundles(), 9);
    /// assert_eq!(s.width(), 16);
    /// ```
    #[must_use]
    pub const fn new(bundles: usize, width: usize) -> Self {
        Self { bundles, width }
    }

    /// The number of bundles in this shape.
    #[must_use]
    pub const fn bundles(self) -> usize {
        self.bundles
    }

    /// The bit width of each bundle.
    #[must_use]
    pub const fn width(self) -> usize {
        self.width
    }
}