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)
- CheckedBlockMac32.lvt
- CheckedBlockMacPrimitive.lvt
- CheckedBlockMacPrimitive.vhd
- IIntegerDivision.lvt
- IntegerDivision.lvt
- IntegerMath.lvt
- MacInt32.lvt
- MacUnit.lvt
- UnsignedDivideInt32.lvt
- UnsignedDivision.lvt
- UnsignedDivisionPipelinePrimitive.lvt
- UnsignedDivisionPipelinePrimitive.vhd
- UnsignedMath.lvt
- WideArithmetic.lvt
- WideArithmeticPrimitive.lvt
- WideArithmeticPrimitive.vhd
src/arithmetic/UnsignedDivideInt32.lvt
namespace Livt.Math.Arithmetic
/**
* Compatibility adapter for nonnegative signed-int32 floor division.
* New consumers can use UnsignedDivision for quotient, remainder, and explicit status.
* Invalid negative inputs or a zero divisor retain the historical zero result.
*/
component UnsignedDivideInt32
{
// Number of magnitude bits accepted by the historical API.
public const ITERATIONS: int = 31
// Shared implementation of exact scheduled division.
divider: UnsignedDivision<31>
/**
* Owns one worker; calls must be serialized.
*/
new()
{
divider = new UnsignedDivision<31>()
}
/**
* Returns the floor quotient, or zero for invalid input.
*/
public fn Compute(dividend: int, divisor: int) int
{
if (dividend < 0 || divisor <= 0) {
return 0
}
return divider.Divide(dividend as uint, divisor as uint) as int
}
}