Skip to main content

FuncUnit

Enum FuncUnit 

Source
pub enum FuncUnit {
Show 21 variants DivS, ModS, FloorDivS, Pow, MulHiU, ApproxEqF, FAddF, FSubF, FMulF, FDivF, FSqrtF, FFloorF, MulOvfS, IntToF, FLtF, FGtF, FLeF, FGeF, FEqF, FNeF, PopCount,
}
Expand description

A SEQUENTIAL functional unit — signed division and remainder. Unlike an AluOp, division is NOT a combinational tile: on silicon it is the multi-cycle shared_divider (already proven ≡ the VM by rtl.rs::the_signed_divider_is_proven_correct_by_our_sat), issued as a functional unit. Keeping it a distinct fabric cell lets the emitter wire that sequential unit rather than synthesize a giant combinational divider. Semantics mirror the soft-core’s shared_divider exactly, INCLUDING the divide-by-zero trap (b == 0 → 0).

Variants§

§

DivS

Truncated signed quotient (Op::Div / Op::ExactDiv, a / b rounding toward zero).

§

ModS

Signed remainder taking the dividend’s sign (Op::Mod, a % b).

§

FloorDivS

Floor division (Op::FloorDiv, a // b rounding toward negative infinity).

§

Pow

Exponentiation (Op::Pow, a ** b) — a SEQUENTIAL multiplier (b multiplies) at the RTL level; the eval is the closed-form wrapping power. The VM promotes to bigint on overflow, so a fabric witness keeps a**b inside i64 (a small const exponent over the bounded fuzz range).

§

MulHiU

UNSIGNED high-half multiply (a·b) >> 64 (both operands as u64) — the reciprocal step of Op::MagicDivU’s magic division. On silicon it is the high word of the 64×64 multiplier; the eval takes the top 64 bits of the 128-bit unsigned product. No divider trap applies (it is a multiply).

§

ApproxEqF

APPROXIMATE equality (Op::ApproxEq, a is approximately b) over NUMERIC operands: both converted to f64, compared by the relative+absolute tolerance logos_approx_eq. Yields 0/1. (Float-typed operands need the float lane; the fabric refuses them at the Constant::Float load, so only the numeric-int case reaches here.) No divider trap — it is a comparison.

§

FAddF

The FLOAT LANE — IEEE-754 f64 operating on the bit-pattern each operand carries (f64::from_bits). Binary FAddF/FSubF/FMulF/FDivF return the result’s bits; unary FSqrtF returns bits; FFloorF returns the floored value as an Int (the float→int bridge, matching the floor builtin). No divider trap (float /0.0 is ±inf, not the integer trap).

§

FSubF

§

FMulF

§

FDivF

§

FSqrtF

§

FFloorF

§

MulOvfS

Signed 128-bit MULTIPLY OVERFLOW flag: 1 iff (a as i128) * (b as i128) does NOT fit i64 (the BigIntWide lane’s “did this product promote to a BigInt?” test — the VM’s Value::mul returns an Int when it fits and a BigInt when it does not). A comparison, so no divider trap.

§

IntToF

INT→FLOAT promotion: reinterpret the operand as a signed i64 value and return the bit pattern of its f64 widening ((a as f64).to_bits()). This is the fabric’s static realization of the VM’s dynamic Int ∘ Float → Float coercion (arith::multiply etc. do *a as f64 when one side is a Float): when a float op has an integer operand, the fabric promotes that operand through this unit first so the float functional unit sees two genuine f64 bit patterns. Unary (b ignored); no divider trap.

§

FLtF

FLOAT COMPARISONS over two f64 bit patterns, yielding the 0/1 predicate the terminator / a Select consumes. A genuine IEEE-754 compare (f64::from_bits(a) < f64::from_bits(b) etc.) — NOT the integer bit-pattern ordering a plain Select would use, which is only sound for same-sign operands and silently wrong once a negative float appears. FEqF/FNeF follow IEEE equality (so NaN != NaN). No divider trap.

§

FGtF

§

FLeF

§

FGeF

§

FEqF

§

FNeF

§

PopCount

POPCOUNT (count_ones): the number of set bits in the operand read as a u64. Unary (b ignored), combinational (a bit-adder tree), yields an Int in 0..=64 — no divider trap. The static realization of the VM’s count_ones builtin / the popcount_leaf hot path.

Implementations§

Source§

impl FuncUnit

Source

pub fn eval(&self, a: i64, b: i64) -> i64

Source

pub fn verilog(&self, a: &str, b: &str) -> String

A COMBINATIONAL-correct Verilog lowering with the b == 0 → 0 guard — semantically identical to the sequential shared_divider (whose FSM instantiation is the area refinement). 64-bit signed, so iverilog’s truncated division/remainder is bit-identical to the VM’s Int.

Source§

impl FuncUnit

Source

pub fn eval_checked(&self, a: i64, b: i64) -> Result<i64, Divergence>

The VM’s value for this unit, or the divergence that keeps the word from being it. Operands follow the unit’s convention (integers by value, floats as f64 bit patterns); so does the result.

Trait Implementations§

Source§

impl Clone for FuncUnit

Source§

fn clone(&self) -> FuncUnit

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FuncUnit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FuncUnit

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for FuncUnit

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for FuncUnit

Source§

fn cmp(&self, other: &FuncUnit) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for FuncUnit

Source§

fn eq(&self, other: &FuncUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for FuncUnit

Source§

fn partial_cmp(&self, other: &FuncUnit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for FuncUnit

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for FuncUnit

Source§

impl Eq for FuncUnit

Source§

impl StructuralPartialEq for FuncUnit

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,