Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public static void RotateAndAdd(
            float[] cosMap,
            uint bits,
            ref ComplexFloat source,
            ref ComplexFloat target,
            uint arg)
        {
            FPGA.Const <uint> mask = GeneratorTools.Mask(bits);

            if (bits == 0)
            {
                target.Re = source.Re;
                target.Im = source.Im;
            }
            else
            {
                float cos = 0.0f, sin = 0.0f;

                uint cosIdx = arg & mask;
                cos = cosMap[cosIdx];

                if (bits > 1)
                {
                    uint sinIdx = (uint)(cosIdx + (cosMap.Length >> 2)) & mask;
                    sin = cosMap[sinIdx];
                }

                target.Re += source.Re * cos - source.Im * sin;
                target.Im += source.Re * sin + source.Im * cos;
            }
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        public static void CopyAndNormalize(
            uint bits,
            ComplexFloat[] source,
            ComplexFloat[] target,
            Direction direction,
            ref ComplexFloat tmpBuff)
        {
            FPGA.Const <float> nFloat = GeneratorTools.FloatArrayLength(bits);

            for (uint i = 0; i < source.Length; i++)
            {
                FPGA.Config.SetInclusiveRange(0, source.Length, i);

                tmpBuff = source[i];

                if (direction == Direction.Forward)
                {
                    tmpBuff.Re = tmpBuff.Re / nFloat;
                    tmpBuff.Im = tmpBuff.Im / nFloat;
                }

                target[i] = tmpBuff;
            }
        }
        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);
        }