示例#1
0
        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.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)];
                ComplexFloat   tmp  = new ComplexFloat();

                while (true)
                {
                    RTX.ReadData(baud, RXD, data);

                    FTTools.CopyAndNormalize(width, data, data, Direction.Forward, ref tmp);

                    RTX.WriteData(baud, TXD, data, 0);
                }
            };

            FPGA.Config.OnStartup(handler);

            Drivers.IsAlive.Blink(LED1);
        }
        public void CopyAndNormalizeController()
        {
            using (var port = new COMPort())
            {
                var sourceSignal = _bp.TestSignal();
                port.Send(sourceSignal);
                ComplexFloat tmp = new ComplexFloat();
                FTTools.CopyAndNormalize(_bp.Bits, sourceSignal, sourceSignal, Direction.Forward, ref tmp);

                var receiverSignal = _bp.ZeroSignal;
                port.Receive(receiverSignal, out uint duration);

                Validation.AssertSpectres(sourceSignal, receiverSignal, true, true);
            }
        }