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 = 0; UART.Read(baud, RXD, out data); 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 static void Transform( uint bits, ComplexFloat[] source, ComplexFloat[] target, Direction direction) { FPGA.Const <uint> length = GeneratorTools.ArrayLength(bits); float[] cosMap = GeneratorTools.CosArray(length, direction); FPGA.Config.NoSync(cosMap, target); var eK = new ComplexFloat(); var oK = new ComplexFloat(); var rotated = new ComplexFloat(); var tmp = new ComplexFloat(); for (uint i = 0; i < source.Length; i++) { uint j = FPGA.Runtime.Reverse(i, bits); tmp = source[i]; target[j] = tmp; } uint m = 1; uint groupSize = length; for (uint i = 0; i < bits; i++) { FPGA.Config.SetInclusiveRange(0, bits, i); groupSize = groupSize >> 1; for (uint group = 0; group < m; group++) { FPGA.Config.SetInclusiveRange(0, bits, i); uint arg = groupSize * group; for (uint idx = group; idx < length; idx += m * 2) { FPGA.Config.SetInclusiveRange(0, bits, i); eK = target[idx]; oK = target[idx + m]; FTTools.Rotate(cosMap, bits, ref oK, ref rotated, arg); tmp.Re = eK.Re + rotated.Re; tmp.Im = eK.Im + rotated.Im; target[idx] = tmp; tmp.Re = eK.Re - rotated.Re; tmp.Im = eK.Im - rotated.Im; target[idx + m] = tmp; } } m = m << 1; } FTTools.CopyAndNormalize(bits, target, target, direction, ref tmp); }