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)
tests/arithmetic/MacInt32Test.lvt
namespace Livt.Math.Tests.Arithmetic
using Livt.Math.Arithmetic
/**
* Exercises MacInt32 with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component MacInt32Test
{
// Shared fixture instances, signals, and observation state.
mac: MacInt32
/**
* Creates the shared fixture instances (MacInt32). Tests initialize the state required by
* their scenario.
*/
new()
{
this.mac = new MacInt32()
}
/**
* Checks that Accumulate s beyond int16.
*/
@Test
fn AccumulatesBeyondInt16()
{
this.mac.Reset()
this.mac.Accumulate(127, 127)
this.mac.Accumulate(127, 127)
this.mac.Accumulate(-2, 5)
this.mac.Add(10)
assert this.mac.GetResult() == 32258
}
/**
* Checks that Reset s to zero.
*/
@Test
fn ResetsToZero()
{
this.mac.Accumulate(1000, 1000)
this.mac.Reset()
assert this.mac.GetResult() == 0
}
}