public static void Transform(uint bits, ComplexFloat[] data, Direction direction) { FPGA.Const <uint> n = GeneratorTools.ArrayLength(bits); FPGA.Const <float> nFloat = GeneratorTools.FloatArrayLength(bits); uint mask = GeneratorTools.Mask(bits); ComplexFloat[] transformed = new ComplexFloat[data.Length]; float[] cosMap = GeneratorTools.CosArray(n, direction); var tmp = new ComplexFloat(); // for each destination element for (uint i = 0; i < n; i++) { tmp.Re = 0.0f; tmp.Im = 0.0f; // sum source elements for (uint j = 0; j < n; j++) { ComplexFloat source = new ComplexFloat(); source = data[j]; FTTools.RotateAndAdd(cosMap, bits, ref source, ref tmp, i * j); } transformed[i] = tmp; } FTTools.CopyAndNormalize(bits, transformed, data, direction, ref tmp); }
public static async Task Aggregator( FPGA.InputSignal <bool> RXD, FPGA.OutputSignal <bool> TXD ) { uint clockCounter = 0; Diag.ClockCounter(clockCounter); Sequential handler = () => { FPU.FPUScopeNoSync(); const int width = 10; const int baud = 115200; ComplexFloat[] source = new ComplexFloat[GeneratorTools.ArrayLength(width)]; ComplexFloat[] target = new ComplexFloat[GeneratorTools.ArrayLength(width)]; FPGA.Config.NoSync(source); while (true) { RTX.ReadData(baud, RXD, source); uint start = clockCounter; FFT.Transform(width, source, target, Direction.Forward); uint end = clockCounter; RTX.WriteData(baud, TXD, target, end - start); } }; FPGA.Config.OnStartup(handler); }
public static async Task Aggregator( FPGA.OutputSignal <bool> LED1, FPGA.InputSignal <bool> RXD, FPGA.OutputSignal <bool> TXD ) { Sequential handler = () => { FPU.FPUScope(); const int width = 10; const int baud = 115200; ComplexFloat[] data = new ComplexFloat[GeneratorTools.ArrayLength(width)]; while (true) { RTX.ReadData(baud, RXD, data); DFT.Transform(width, data, Direction.Forward); RTX.WriteData(baud, TXD, data, 0); } }; FPGA.Config.OnStartup(handler); Drivers.IsAlive.Blink(LED1); }
public static async Task Aggregator( FPGA.OutputSignal <bool> LED1, FPGA.InputSignal <bool> RXD, FPGA.OutputSignal <bool> TXD ) { Sequential handler = () => { FPU.FPUScope(); const int width = 10; const int baud = 115200; while (true) { byte data = UART.Read(baud, RXD); uint length = GeneratorTools.ArrayLength(width); for (uint i = 0; i < length; i++) { uint reversed = FPGA.Runtime.Reverse(i, width); UART.WriteUnsigned32(baud, reversed, TXD); } } }; FPGA.Config.OnStartup(handler); Drivers.IsAlive.Blink(LED1); }
public static async Task Aggregator( FPGA.OutputSignal <bool> LED1, FPGA.InputSignal <bool> RXD, FPGA.OutputSignal <bool> TXD ) { Sequential handler = () => { FPU.FPUScope(); const int width = 10; const int baud = 115200; ComplexFloat[] data = new ComplexFloat[GeneratorTools.ArrayLength(width)]; while (true) { RTX.ReadData(baud, RXD, data); for (int idx = 0; idx < data.Length; idx++) { ComplexFloat tmp = new ComplexFloat(); tmp = data[idx]; tmp.Re = 1024f; tmp.Im = tmp.Im + 10f; data[idx] = tmp; } RTX.WriteData(baud, TXD, data, 0); } }; FPGA.Config.OnStartup(handler); Drivers.IsAlive.Blink(LED1); }
public void ZeroLength() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => GeneratorTools.ArrayLength(0)); }
public void Length16bits() { Assert.AreEqual(65536u, GeneratorTools.ArrayLength(16)); }
public void Length10bits() { Assert.AreEqual(1024u, GeneratorTools.ArrayLength(10)); }