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/lookup/TrigQ15Test.lvt
namespace Livt.Math.Tests.Lookup
using Livt.Math.Lookup
/**
* Exercises TrigQ15 with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component TrigQ15Test
{
// Shared fixture instances, signals, and observation state.
trig: TrigQ15
/**
* Creates the shared fixture instances (TrigQ15). Tests initialize the state required by
* their scenario.
*/
new()
{
trig = new TrigQ15()
}
/**
* Checks that the component returns known size four values.
*/
@Test
fn ReturnsKnownSizeFourValues()
{
assert trig.Cos(0, 4) == 32767
assert trig.Sin(1, 4) == 32767
assert trig.Cos(2, 4) == -32768
assert trig.Sin(3, 4) == -32768
}
/**
* Checks that the component returns known size eight values.
*/
@Test
fn ReturnsKnownSizeEightValues()
{
assert trig.Cos(1, 8) == 23170
assert trig.Sin(1, 8) == 23170
assert trig.Cos(5, 8) == -23170
assert trig.Sin(7, 8) == -23170
}
/**
* Checks that the component wraps indexes.
*/
@Test
fn WrapsIndexes()
{
assert trig.Cos(8, 8) == 32767
assert trig.Sin(-1, 4) == -32768
}
/**
* Checks that the component uses safe defaults for unsupported size.
*/
@Test
fn UsesSafeDefaultsForUnsupportedSize()
{
assert trig.Cos(1, 16) == 32767
assert trig.Sin(1, 16) == 0
}
}