Livt packages

Livt.Math

Version 1.7.2

Reusable integer and fixed-point arithmetic, complex numbers, trigonometry, and statistics for FPGA applications written in Livt.

Published files (90)

src/arithmetic/IIntegerDivision.lvt

namespace Livt.Math.Arithmetic

/**
 * Exact scheduled integer division. One owner serializes all calls and observations.
 * Compute produces quotient and remainder together; readers do not start another divide.
 * Divide and Remainder follow truncation toward zero (floor for unsigned values).
 * ModuloEuclidean is nonnegative, including when either signed operand is negative.
 * Invalid operands return zero results and set Failed; successful computation clears it.
 * Reset cancels a pending call and clears results/status. No cycle count is implied here.
 */
interface IIntegerDivision<T>
{
	/**
	 * Computes both results, returning false on invalid operands or quotient overflow.
	 */
	fn Compute(dividend: T, divisor: T) bool

	/**
	 * Returns the quotient of the latest computation, or zero after failure/reset.
	 */
	fn GetQuotient() T

	/**
	 * Returns the remainder of the latest computation; signed remainder follows dividend.
	 */
	fn GetRemainder() T

	/**
	 * Computes and returns the quotient; inspect Failed to distinguish invalid division.
	 */
	fn Divide(dividend: T, divisor: T) T

	/**
	 * Computes and returns the remainder; inspect Failed for invalid division.
	 */
	fn Remainder(dividend: T, divisor: T) T

	/**
	 * Computes the residue in [0, abs(divisor)); inspect Failed for invalid division.
	 */
	fn ModuloEuclidean(dividend: T, divisor: T) T

	/**
	 * Reports invalid operands or quotient overflow in the latest computation.
	 */
	fn Failed() bool
}