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/MacInt32.lvt
namespace Livt.Math.Arithmetic
/**
* Accumulates signed products using Livt's int32 arithmetic.
*
* Callers must keep the mathematical sum inside the signed int32 range. This
* component deliberately does not apply the int16 saturation used by MacUnit.
*/
component MacInt32
{
// Running sum retained until Reset starts another reduction.
accumulator: int
/**
* Adds one signed product to the stored accumulator.
*/
public fn Accumulate(a: int, b: int)
{
accumulator = accumulator + a * b
}
/**
* Adds one signed value to the stored accumulator.
*/
public fn Add(value: int)
{
accumulator = accumulator + value
}
/**
* Returns the current accumulator value.
*/
public fn GetResult() int
{
return accumulator
}
/**
* Resets the accumulator to zero.
*/
public fn Reset()
{
accumulator = 0
}
}